本文介绍了WPF样式触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在样式触发器中更改了文本的FontSize,这也会导致包含文本的控件也重新调整大小。如何更改字号而不影响父级的尺寸?
I change the FontSize of Text in a Style trigger, this causes the Control containing the text to resize as well. How can I change the Fontsize without affecting the parent's size?
推荐答案将元素与其父级布局隔离的一个不错的技巧是将元素放置在画布中
A nice trick to isolate an element from its parent layout wise is to place the element in a Canvas
在下面的标记中,元素有两个副本第一个是隐藏的并确定控件的大小第二个是可见的但包裹在Canvas中,因此
In the markup below there are two copies of your element The first is hidden and establishes the size of your control The second is visible but wrapped in a Canvas so its layout size does not affect the parent.
<Parent> <Grid> <Element Visibility="Hidden"/> <Canvas> <Element /> </Canvas> <Grid> </Parent>更多推荐
WPF样式触发器
发布评论