有没有一种方法可以缩放viewbox的内容,除了一个控件?我有一个带网格的viewbox,在这个网格中我有一些控件,我试图缩放viewbox中除一个控件之外的所有控件,这是可能的吗?
非常感谢,保罗
发布于 2009-08-25 10:33:24
可以使用网格将图层添加到布局中。这样,您可以缩放一组项目,而不缩放另一组项目。
<Grid>
<Viewbox>
<!-- Controls to zoom -->
</Viewbox>
<!-- Control to exclude from zoom -->
</Grid>视图框和XAML中其他控件的顺序将取决于显示在顶部的层。
如果这不能完全满足你的需求,请留言,我会重新考虑你的答案。
编辑您希望未缩放的控件相对于Viewbox的(0,0)定位。在这种情况下会发生这种情况,因为网格的两个孩子都在单元格(0,0)中,这意味着它们的左上角是对齐的。您能否举例说明您在XAML中所拥有的内容,以及它的问题所在(也许可以编辑您的原始问题)?
下面是一些可以尝试的XAML:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Background="Green">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox>
<Rectangle Fill="Yellow" Width="10" Height="10" />
</Viewbox>
<TextBlock>I am positioned at (0,0)</TextBlock>
<TextBlock Margin="50,50">I am positioned at (50,50)</TextBlock>
</Grid>
</Page>这给出了一个类似这样的布局:
http://img20.imageshack.us/img20/2045/layout1m.png
但请注意,当高度减小时,网格将变得比视图框更宽,因此内容布局如下:
http://img20.imageshack.us/img20/9397/layout2i.png
我想这不是你想要的。在这种情况下,您可以使用画布,然后执行以下操作:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Background="Green">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox>
<Rectangle Fill="Yellow" Width="10" Height="10" />
</Viewbox>
<Canvas>
<TextBlock>I am positioned at (0,0)</TextBlock>
<TextBlock Margin="50,50">I am positioned at (50,50)</TextBlock>
</Canvas>
</Grid>
</Page>它看起来像这样:
http://img20.imageshack.us/img20/6743/layout3i.png
https://stackoverflow.com/questions/1327312
复制相似问题