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

后端 未结 5 658
北恋
北恋 2021-02-13 02:15

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


    
        

        
5条回答
  •  野性不改
    2021-02-13 02:44

    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:

    
     
      
     
    
     
        
            
        
     
    

提交回复
热议问题