Hi,
I'm trying to bind the background of a GridViewDataColumn to a property in my ViewModel:
Based on the value of the State property the background should change: if State = new, the background should be green, if State = rejected the value should be red, and so on.
However, if I bind the State property to the Background, i get a BindingExpression path error stating that my State property is not found on my object, while the same databinding works fine on the DataMemberBinding.
Anyone got a clue what is wrong here?
The Xaml:
and the code from the viewModel:
Thanks a lot!
Hans
I'm trying to bind the background of a GridViewDataColumn to a property in my ViewModel:
| <radGrid:GridViewDataColumn Header="State" Width="090" Background="{Binding Path=State, Converter={StaticResource StateToColorConverter}}" DataMemberBinding="{Binding Path=State}"/> |
Based on the value of the State property the background should change: if State = new, the background should be green, if State = rejected the value should be red, and so on.
However, if I bind the State property to the Background, i get a BindingExpression path error stating that my State property is not found on my object, while the same databinding works fine on the DataMemberBinding.
Anyone got a clue what is wrong here?
The Xaml:
| <radGrid:RadGridView ItemsSource="{Binding Orders}" > |
| <radGrid:RadGridView.Columns> |
| <radGrid:GridViewDataColumn Header="State" Width="090" Background="{Binding Path=State, Converter={StaticResource StateToColorConverter}}" DataMemberBinding="{Binding Path=State}"/> |
| </radGrid:RadGridView.Columns> |
| </radGrid:RadGridView> |
and the code from the viewModel:
| private ObservableCollection<SingleOrder> _orders = new ObservableCollection<SingleOrder>() |
| public ObservableCollection<SingleOrder> Orders { get { return _orders; } } |
| public class SingleOrder |
| : ViewModelBase |
| { |
| private Instrument _instrument; |
| public Instrument Instrument |
| { |
| get { return _instrument; } |
| set |
| { |
| if (!Instrument.Equals(_instrument, value)) |
| { |
| _instrument = value; |
| this.OnPropertyChanged("Instrument"); |
| } |
| } |
| } |
| private System.String _state; |
| public System.String State |
| { |
| get { return _state; } |
| set |
| { |
| if (!String.Equals(_state, value)) |
| { |
| _state = value; |
| this.OnPropertyChanged("State"); |
| } |
| } |
| } |
| } |
Thanks a lot!
Hans