I’ve got question about wpf xaml style definitions. When I try to set style in this way:
<StackPanel Orientation="Vertical">
<StackPanel.Style>
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</StackPanel.Style>
</StackPanel>
raises exception with message – 'System.Windows.Setter' is not a valid value for property 'Style'.
when I use this definition:
<Style x:Key="itemBehaviour" >
<Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</Style>
<StackPanel Orientation="Vertical" Style="{StaticResource itemBehaviour}">
everything works fine.
So, what is the difference?
StackPanel.Styleis a property of typeStyle, so without wrapping theSetterin<Style></Style>you’re trying to set theStyleproperty to something of typeSetter.