I have the fragment below as contents of a <Gridelement. The idea is that
if the checkbox is checked the <TreeViewelement should only span one
instead of two columns. When I check the checkbox the background of the
treeview turns red, but the treeview continues to span 2 instead of 1
column. It's a bit like the attached property Grid.ColumnSpan does not get
assigned by the <Setter Property="Grid.ColumnSpan" Value="1"/at all. What
should I do in order to achieve what I want?
Best regards,
Henrik Dahl
<TreeView
x:Name="Blas"
ItemsSource="{Binding Path=BlasRoot.Children}" d:LayoutOverrides="Width"
Margin="0,0,0,8" Grid.Column="0" Grid.ColumnSpan="2">
<TreeView.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=chkPosition,
Path=IsChecked}" Value="True">
<Setter Property="Grid.ColumnSpan" Value="1"/>
<Setter Property="TreeView.Background" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TreeView.Style>
</TreeView>
<CheckBox HorizontalAlignment="Left" Margin="-50,0,0,0" x:Name="chkPosition"
VerticalAlignment="Top" Content="CheckBox">
</CheckBox>