C#/WPF: Make a GridViewColumn Visible=false?

后端 未结 5 966
无人共我
无人共我 2021-02-13 02:08

Does anyone know if there is an option to hide a GridViewColumn somehow like this:


    
        

        
5条回答
  •  伪装坚强ぢ
    2021-02-13 02:22

    Edit: Reflecting the modified question.

    What about creating a 0 width column? Write a Boolean to Width IValueConverter, that takes a ColumnIsVisible as the ConverterParmeter?

     public class BooleanToWidthConverter : IValueConverter {
            public object Convert(object value, Type targetType, 
                                  object parameter, CultureInfo culture){
                return ((bool) parameter)? value : 0;
            }
     
            public object ConvertBack(object value, Type targetType, 
                                      object parameter, CultureInfo culture){
                throw new NotImplementedException();
            }
        }
    

    Something like:

    
     
      
     
    
     
        
            
        
     
    

提交回复
热议问题