WPF - 如何以样式设置 Grid 的子项? [英] WPF - How to set Grid's children in a style?
本文介绍了WPF - 如何以样式设置 Grid 的子项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何做这样的事情?
How can I do something like this?
<Style TargetType="Grid">
<Setter Property="Children">
<Setter.Value>
...
</Setter.Value>
</Setter>
</Style>
我知道 Children 处于只读状态,这使我对 Children 具有预期的可写属性".
I know Children in read-only and this gives me "Writable property expected" on Children.
谢谢
推荐答案
你不能,因为 Panel.Children
不是 DependencyProperty
.您几乎肯定希望使用带有自定义 ItemsPanel
的 ItemsControl
.但是,没有更多信息,我无法确定.
You can't because Panel.Children
is not a DependencyProperty
. You almost certainly want to use an ItemsControl
with a customized ItemsPanel
. However, without more information I couldn't really say for sure.
这篇关于WPF - 如何以样式设置 Grid 的子项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文