Reputation: 495
I have custom treelistview and I put a checkbox in the first column of my treelistview. everything is ok but when I want to hide the checkbox column for other purpose (using variable SelectEnable) , it does not hide correctly(it hides but a blank area remains). This Problem happens when I load the data (I mean when treelistview is empty, the column is hidden).
here is some pieces of my xaml:
<Style x:Key="checkboxColumnStyle"
TargetType="GridViewColumnHeader">
<Setter Property="Width"
Value="0" />
<Setter Property="Visibility"
Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SelectEnable}"
Value="False">
<Setter Property="Visibility"
Value="Hidden" />
<Setter Property="Width"
Value="0" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SelectEnable}"
Value="True">
<Setter Property="Visibility"
Value="Visible" />
<Setter Property="Width"
Value="30" />
</DataTrigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="CellTemplate_checkBox">
<CheckBox IsChecked="{Binding IsSelected}"
VerticalAlignment="Center"
Style="{DynamicResource checkboxStyle}"
Tag="{Binding}"
Checked="CheckBox_Checked"
Unchecked="CheckBox_Checked" />
</DataTemplate>
<GridViewColumnCollection x:Key="gvcc">
<GridViewColumn CellTemplate="{StaticResource CellTemplate_checkBox}">
<GridViewColumnHeader Style="{DynamicResource checkboxColumnStyle}"
MaxWidth="0">
<CheckBox x:Name="chechBoxAll"
Style="{DynamicResource checkboxStyle}"
Checked="chechBoxAll_Checked"
Unchecked="chechBoxAll_Checked" />
</GridViewColumnHeader>
</GridViewColumn>
<!--Other Columns -->
</GridViewColumnCollection>
How can i fix this?
Upvotes: 0
Views: 132
Reputation: 57959
You probably want Visibility.Collapsed
instead of Visibility.Hidden
.
Hidden
means the element is there but cannot be seen (similar to Opacity
of 0), whereas Collapsed
causes the layout arrangement to happen as though the element does not exist (no width and no height).
Upvotes: 3