WPF DataTrigger to display and hide grid column XAML

前端 未结 1 1516
眼角桃花
眼角桃花 2021-02-07 22:03

I have an WPF application that contains a grid. The grid is split into 3 columns with the 3rd grid having zero width upon loading.

I have two datagrids in the other two

1条回答
  •  遥遥无期
    2021-02-07 22:31

    Using the correct DataTrigger, this is totally possible. First, add the Trigger to the UI element that you want to change... the ColumnDefinition, not the Grid:

    
        
            
        
    
    

    Next, don't set the Width on the ColumnDefinition element, but in the Style instead. Otherwise the Width on the ColumnDefinition element will override the value set from the DataTrigger.

    0 讨论(0)
提交回复
热议问题