0
我該如何做這樣的事情?WPF - 如何設置網格的孩子的風格?
<Style TargetType="Grid">
<Setter Property="Children">
<Setter.Value>
...
</Setter.Value>
</Setter>
</Style>
我知道兒童在只讀,這給了我「兒童可預見的財產」。
感謝
我該如何做這樣的事情?WPF - 如何設置網格的孩子的風格?
<Style TargetType="Grid">
<Setter Property="Children">
<Setter.Value>
...
</Setter.Value>
</Setter>
</Style>
我知道兒童在只讀,這給了我「兒童可預見的財產」。
感謝
你不能因爲Panel.Children
不是DependencyProperty
。您幾乎肯定希望使用ItemsControl
和定製的ItemsPanel
。但是,沒有更多的信息,我無法確切地說。
可以使用ContentControl中,而不是電網,並與控件模板/ DataTemplate中包含您的網格
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
...
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ContentControl.Style>
</ContentControl>
或
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
...
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ContentControl.Style>
</ContentControl>
你網格項目綁定到任何設置它的模板/的ContentTemplate屬性? – Rachel 2010-08-20 18:49:03
蕾切爾,不,我不是。雖然以綁定的形式造型。這就是爲什麼我認爲這不起作用 - 因爲兒童不是DP,它不能用於綁定,而且Styling也是有約束力的。 – 2010-08-20 19:33:52