Silverlight/XAML 设计问题 - 水平对齐(对接?)
我有一个关于使用什么 XAML 来实现我的设计的问题。我当前在屏幕上有一个图像区域,宽度可能会有所不同。在图像上方,我有两个工具栏,每个工具栏都有许多按钮。其中一个我想浮动/停靠到图像的左边缘,另一个我想浮动/停靠到图像的右边缘。当然,随着图像变大,右侧的工具箱应保持停靠在右边缘。如何才能实现这一目标?
+--------------------------+ +---------------+
| TOOLBAR 1 | | TOOLBAR 2 |
+--------------------------+ +---------------+
+---------------------------------------------------------------------------+
| |
| |
| |
| <----- VARIABLE-WIDTH IMAGE -----> |
| |
| |
| |
+---------------------------------------------------------------------------+
任何 XAML 代码示例和简短解释将不胜感激。我是个菜鸟。
I have a question regarding what XAML to use to achieve my design. I currently have an Image area on the screen, the width can vary. Above the image, I have two toolbars, each with numerous buttons. One of them I want to float/dock to the left edge of the image, and the other one I want to float/dock to the right edge. Of course, as the image gets bigger the toolbox on the right should remain docked to the right edge. How can this be achieved?
+--------------------------+ +---------------+
| TOOLBAR 1 | | TOOLBAR 2 |
+--------------------------+ +---------------+
+---------------------------------------------------------------------------+
| |
| |
| |
| <----- VARIABLE-WIDTH IMAGE -----> |
| |
| |
| |
+---------------------------------------------------------------------------+
Any XAML code samples and brief explanation would be greatly appreciated. I'm a noob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用两行两列的网格(列宽设置为自动)。图像将跨越第二行的两列。网格的大小适合其内容,并且随着网格的增长(因为图像已经增长),右对齐的工具栏将相应地移动以保持与图像对齐。下面是 XAML 中的示例,使用矩形代替工具栏和图像:
更改名为“Image”的矩形的宽度以查看效果。
希望这有帮助......
克里斯
Use a grid with two rows and two columns (with the column widths set to Auto). The image will span both columns on the second row. The grid with size to its content, and as the grid grows (because the image has grown), the right aligned toolbar will move to remain aligned with the image accordingly. Here's an example in XAML, using rectangles in place of the toolbars and images:
Change the width of the Rectangle named "Image" to see the effect.
Hope this helps...
Chris