In my WPF apllication I want to hide column in DataGrid with binding ItemsSource by adding [Browsable(false)] to some properties But, with or without Browsable(false) all columns are visible.
My model:
public class Room : INotifyPropertyChanged
{
private int id;
...
[Browsable(false)]
public int Id
{
get
{
return this.id;
}
set
{
this.id = value;
this.OnPropertyChanged("Id");
}
}
...
public Room()
{
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
if (propertyChangedEventHandler != null)
{
propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
View:
<DataGrid Grid.Row="1" ItemsSource="{Binding Rooms}" SelectedItem="{Binding SelectedRoom, Mode=TwoWay}" />
How can I use Browsable(false) to hide columns?