WPF 视图框缩放
除了一个控件之外,有没有一种方法可以缩放视图框内容? 我有一个带有网格的视图框,在这个网格中我有一些控件,我试图缩放视图框中除一个控件之外的所有控件,这可能吗?
非常感谢, 保罗
Is there a way to zoom a viewbox content, excpet for one control?
I have a viewbox with a grid, and in this grid I have some controls and I'm trying to zoom all the controls in the viewbox except one, is it possible?
Many thanks,
Paulo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用网格向布局添加图层。这样,您可以缩放一组项目,而使另一组保持不缩放。
XAML 中视图框和其他控件的顺序将取决于显示在顶部的层。
如果这不能完全满足您的要求,请发表评论,我将重新审视答案。
编辑您希望未缩放的控件相对于
Viewbox
的(0,0)定位。在这种情况下会发生这种情况,因为网格的两个子项都位于单元格 (0,0) 中,这意味着它们的左上角对齐。您能否举例说明 XAML 中的内容以及它有什么问题(也许编辑您原来的问题)?下面是一些可以尝试的 XAML:
给出如下布局:
http://img20.imageshack.us/img20/2045 /layout1m.png
但请注意,当高度减小时,网格会变得比视图框更宽,因此内容的布局如下:
http://img20.imageshack.us/img20/9397/layout2i.png
我想这不是你想要的。在这种情况下,您可以使用画布并进行如下操作:
看起来像这样:
http://img20。 imageshack.us/img20/6743/layout3i.png
You can use a grid to add layers to your layout. That way, you can zoom one set of items, and leave another set un-zoomed.
The order of the view box and the other controls in XAML will depend upon which layer appears on top.
If that doesn't quite do what you want, leave a comment and I'll revisit the answer.
EDIT You want the unzoomed control to be positioned relative to the (0,0) of the
Viewbox
. That will happen in this situation because both children of the grid are in cell (0,0) which means that their top-left corners are aligned. Can you give an example of what you have in XAML, and what's wrong with it (perhaps edit your original question)?Here's some XAML to try:
That gives a layout like this:
http://img20.imageshack.us/img20/2045/layout1m.png
But note that when the height is reduced, the grid becomes wider than the view box, and so the content is layed out like this:
http://img20.imageshack.us/img20/9397/layout2i.png
I guess that's not what you want. In that case, you use a canvas and go for something like this:
Which looks like this:
http://img20.imageshack.us/img20/6743/layout3i.png