Hi All,
Can someone please help me. I need to change my Cell Background color, The user can select a color with a color picker that gets stored in configuration.
public SolidColorBrush SolidColorBrushValue { get { return MatrixView.SolidColorBrushValue; } set { if (MatrixView.SolidColorBrushValue!= value) { MatrixView.SolidColorBrushValue= value; RaisePropertyChanged("SolidColorBrushValue"); } } }
<Style x:Key="CellLockedStyle" TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Background" Value="{Binding SolidColorBrushValue}"></Setter> <Setter Property="IsEnabled" Value="True"></Setter> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> </Style>
The color does not change when the property is triggered.
Thanks in advance,
Roelof
Hello Roelof,
It appears from the code that you have provided that you are trying to bind the Background property of the CellValuePresenter directly to your SolidColorBrushValue property, which I presume is on your underlying data item. This will not work, as the data context of the CellValuePresenter is the DataRecord that holds the cell that is being presented. This DataRecord has a DataItem property, though, which can be used to get your underlying data item and bind to the properties on it. As such, I would recommend reformatting your binding to look like the following:
<Setter Property="Background" Value="{Binding DataItem.SolidColorBrushValue}"></Setter>
It is also worth noting that you may be able to use a CellBinding to achieve your requirement in this case, rather than using a Style for CellValuePresenter. You can read about CellBindings in our online documentation, here.
Please let me know if you have any other questions or concerns on this matter.
HI Andrew,
Sorry for taking so long to get back to you. I've tried to implement the change but it does not seem to work. I've attached an example project.
If you could assist it would be appreciated.
0728.NewGridTest.zip
Thanks,