Hi, sorry if this is a basic question, but I looked through the first 7 pages worth of posts and didn't see anything exactly like what I am trying to accomplish. The requirement I have is that I have to display data in a grid but sometimes the data is read only and some times the data is editable on a per-cell basis. For example take this simple class:
As you can see there is a Value property and a CanEditValue property. If I load up an ObservableCollection with these and set the ItemsSource of the GridView to the collection, I want to be able to change the CellStyle per row based on the CanEditValue property. Specifically the user wants to see a white background for read-only data and a beige background for editable data. Obviously the actual data would have more than one column, but this example shows what I'm trying to accomplish. I'd prefer to do this through binding rather than programmatically in case the user changes their mind about the specific styling.
Any assistance is appreciated!
Dan
public class GridDataItem:INotifyPropertyChanged |
{ |
private int _value; |
public int Value |
{ |
get { return _value;} |
set { _value = value; OnPropertyChanged("Value");} |
} |
private bool _canEditValue; |
public bool CanEditValue |
{ |
get { return _canEditValue; } |
set { _canEditValue = value; OnPropertyChanged("CanEditValue"); } |
} |
#region INotifyPropertyChanged Members |
public event PropertyChangedEventHandler PropertyChanged; |
#endregion |
private void OnPropertyChanged(string propName) |
{ |
if (PropertyChanged != null) |
{ |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
} |
} |
} |
As you can see there is a Value property and a CanEditValue property. If I load up an ObservableCollection with these and set the ItemsSource of the GridView to the collection, I want to be able to change the CellStyle per row based on the CanEditValue property. Specifically the user wants to see a white background for read-only data and a beige background for editable data. Obviously the actual data would have more than one column, but this example shows what I'm trying to accomplish. I'd prefer to do this through binding rather than programmatically in case the user changes their mind about the specific styling.
Any assistance is appreciated!
Dan