WPF样式触发器

编程入门 行业动态 更新时间:2024-10-27 10:19:10
本文介绍了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样式触发器

本文发布于:2023-11-06 04:50:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:触发器   样式   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!