[英]WPF ViewBox Zoom
有没有一种方法可以缩放视图框的内容,一个控件只能使用expet? 我有一个带有网格的视图框,并且在此网格中有一些控件,并且我试图缩放视图框中除一个控件之外的所有控件,这可能吗?
非常感谢Paulo
您可以使用网格将图层添加到布局中。 这样,您可以缩放一组项目,而使另一组不缩放。
<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>
看起来像这样:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.