The color gets set correctly when the rows are loaded and entities created, but when the bound property on an entity gets changed, the color doesn't change.
I'm setting up the binding in the GridView's RowLoaded event:
private
void
ReferenceGrid_RowLoaded(
object
sender, RowLoadedEventArgs e)
{
Binding binding =
new
Binding(
"Status"
);
binding.Mode = BindingMode.OneWay;
e.Row.SetBinding(GridViewRowItem.ForegroundProperty, binding);
}
The entity's Status property (bound above) is a SolidColorBrush
ColorBrushes are defined this way
<SolidColorBrush x:Key=
"GreenColorBrush"
Color=
"Green"
/>
<SolidColorBrush x:Key=
"BlueColorBrush"
Color=
"Blue"
/>
<SolidColorBrush x:Key=
"BlackColorBrush"
Color=
"Black"
/>
<SolidColorBrush x:Key=
"OrangeColorBrush"
Color=
"Orange"
/>
<SolidColorBrush x:Key=
"RedColorBrush"
Color=
"Red"
/>
And here is the definition of the Status property on my entity...
public
SolidColorBrush Status
{
get
{
if
(!ActiveFlag)
{
return
(SolidColorBrush App.Current.Resources[
"OrangeColorBrush"
];
}
return
(SolidColorBrush)App.Current.Resources[
"RedColorBrush"
];
}
}
When the rows are loaded, the framework calls the "getter" on the Status property. The rows on the screen are correctly colored, either orange or red.
The user can change the "ActiveFlag" via a checkbox on the row.
When the user does this, my partial method OnActiveFlagChanged is called. Here is that method...
partial
void
OnActiveFlagChanged()
{
RaisePropertyChanged(
"Status"
);
}
I have verified in the debugger that this method gets called.
Then the framework accesses the "getter" for the Status property, which is expected since the property changed event for this property was just raised.
I have verified in the debugger that the Status property's get method is called, and also that the new color brush is returned from the property.
This all works as expected. The only problem is that the color on the screen doesn't change.
What am I missing?
Thanks,
Mike Maddux