我对wpf xaml样式定义有疑问。当我尝试以这种方式设置样式时:
<StackPanel Orientation="Vertical">
<StackPanel.Style>
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</StackPanel.Style>
</StackPanel>使用message - 'System.Windows.Setter' is not a valid value for property 'Style'引发异常。
当我使用这个定义时:
<Style x:Key="itemBehaviour" >
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</Style>
<StackPanel Orientation="Vertical" Style="{StaticResource itemBehaviour}">一切都很好。
那么,有什么不同呢?
发布于 2010-04-16 21:06:03
StackPanel.Style是一个Style类型的属性,因此在不将Setter包装在<Style></Style>中的情况下,您可以尝试将Style属性设置为Setter类型的内容。
<StackPanel.Style>
<Style>
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</Style>
</StackPanel.Style> https://stackoverflow.com/questions/2653061
复制相似问题