Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Conditional cell hiding
posted

I'm new in WPF and xamlDataGrid. I try to hide cell using trigger. Cell visibility is based on value of other bounded object's property (IsChecked)
It works but there is empty space where collapsed column was placed.
If I don't use trigger in style and simply collapce cell without condition (see commented xaml code) then there is no empty space.

How to collapse cell using trigger without remaining empty space?

 Off: How to format xml-code in this forum?

 <

 

 

igDP:XamDataGrid Margin="12,37,12,12" Name="xamDataGrid1">

 

 

<igDP:XamDataGrid.Resources>

 

 

<Style x:Key="HiddenCell" TargetType="{x:Type igDP:CellPresenter}">

 

 

<!--<Setter Property="Visibility" Value="Collapsed"/>-->

 

 

<Style.Triggers>

 

 

<DataTrigger Binding="{Binding Path=DataItem.IsChecked}" Value="false">

 

 

<Setter Property="Visibility" Value="Collapsed"/>

 

 

</DataTrigger>

 

 

</Style.Triggers>

 

 

</Style>

 

 

</igDP:XamDataGrid.Resources>

 

 

<igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" LabelLocation="InCells"/>

 

 

</igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:XamDataGrid.FieldLayouts>

 

 

<igDP:FieldLayout>

 

 

<igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldSettings CellContentAlignment="LabelLeftOfValueAlignBottom"/>

 

 

</igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldLayout.Fields>

 

 

<igDP:Field Name="FirstName" Label="First Name"/>

 

 

<igDP:Field Name="LastName" Label="Last Name" Column="1"/>

 

 

<igDP:Field Name="RecordDate" Label="Record date" Row="1">

 

 

<igDP:Field.Settings>

 

 

<igDP:FieldSettings CellPresenterStyle="{StaticResource HiddenCell}"/>

 

 

</igDP:Field.Settings>

 

 

</igDP:Field>

 

 

<igDP:Field Name="IsChecked" Label="Checked" Row="2"/>

 

 

</igDP:FieldLayout.Fields>

 

 

</igDP:FieldLayout>

 

 

</igDP:XamDataGrid.FieldLayouts>

 

 

</igDP:XamDataGrid>

 

 

igDP:XamDataGrid Margin="12,37,12,12" Name="xamDataGrid1">

 

 

<igDP:XamDataGrid.Resources>

 

 

<Style x:Key="HiddenCell" TargetType="{x:Type igDP:CellPresenter}">

 

 

<!--<Setter Property="Visibility" Value="Collapsed"/>-->

 

 

<Style.Triggers>

 

 

<DataTrigger Binding="{Binding Path=DataItem.IsChecked}" Value="false">

 

 

<Setter Property="Visibility" Value="Collapsed"/>

 

 

</DataTrigger>

 

 

</Style.Triggers>

 

 

</Style>

 

 

</igDP:XamDataGrid.Resources>

 

 

<igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" LabelLocation="InCells"/>

 

 

</igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:XamDataGrid.FieldLayouts>

 

 

<igDP:FieldLayout>

 

 

<igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldSettings CellContentAlignment="LabelLeftOfValueAlignBottom"/>

 

 

</igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldLayout.Fields>

 

 

<igDP:Field Name="FirstName" Label="First Name"/>

 

 

<igDP:Field Name="LastName" Label="Last Name" Column="1"/>

 

 

<igDP:Field Name="RecordDate" Label="Record date" Row="1">

 

 

<igDP:Field.Settings>

 

 

<igDP:FieldSettings CellPresenterStyle="{StaticResource HiddenCell}"/>

 

 

</igDP:Field.Settings>

 

 

</igDP:Field>

 

 

<igDP:Field Name="IsChecked" Label="Checked" Row="2"/>

 

 

</igDP:FieldLayout.Fields>

 

 

</igDP:FieldLayout>

 

 

</igDP:XamDataGrid.FieldLayouts>

 

 

</igDP:XamDataGrid>

 

igDP:XamDataGrid Margin="12,37,12,12" Name="xamDataGrid1">

 

 

<igDP:XamDataGrid.Resources>

 

 

<Style x:Key="HiddenCell" TargetType="{x:Type igDP:CellPresenter}">

 

 

<!--<Setter Property="Visibility" Value="Collapsed"/>-->

 

 

<Style.Triggers>

 

 

<DataTrigger Binding="{Binding Path=DataItem.IsChecked}" Value="false">

 

 

<Setter Property="Visibility" Value="Collapsed"/>

 

 

</DataTrigger>

 

 

</Style.Triggers>

 

 

</Style>

 

 

</igDP:XamDataGrid.Resources>

 

 

<igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" LabelLocation="InCells"/>

 

 

</igDP:XamDataGrid.FieldLayoutSettings>

 

 

<igDP:XamDataGrid.FieldLayouts>

 

 

<igDP:FieldLayout>

 

 

<igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldSettings CellContentAlignment="LabelLeftOfValueAlignBottom"/>

 

 

</igDP:FieldLayout.FieldSettings>

 

 

<igDP:FieldLayout.Fields>

 

 

<igDP:Field Name="FirstName" Label="First Name"/>

 

 

<igDP:Field Name="LastName" Label="Last Name" Column="1"/>

 

 

<igDP:Field Name="RecordDate" Label="Record date" Row="1">

 

 

<igDP:Field.Settings>

 

 

<igDP:FieldSettings CellPresenterStyle="{StaticResource HiddenCell}"/>

 

 

</igDP:Field.Settings>

 

 

</igDP:Field>

 

 

<igDP:Field Name="IsChecked" Label="Checked" Row="2"/>

 

 

</igDP:FieldLayout.Fields>

 

 

</igDP:FieldLayout>

 

 

</igDP:XamDataGrid.FieldLayouts>

 

 

</igDP:XamDataGrid>

 

 

Parents
No Data
Reply
  • 69686
    posted

    Hello, 

    I was not able to reproduce this. Can you please give us the code you are using to hide the CellPresenter in procedura code?

Children