我对 wpf xaml 样式定义有疑问。当我尝试以这种方式设置样式时:
<StackPanel Orientation="Vertical">
<StackPanel.Style>
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</StackPanel.Style>
</StackPanel>
引发异常消息 - '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}">
一切正常。
那么区别是什么呢?