WPF DataTrigger to display and hide grid column XAML

前端 未结 1 766
半阙折子戏
半阙折子戏 2021-02-07 22:18

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:50

    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)
提交回复
热议问题