Hi I have a xaml app that has one particular color used in many places on a page. I want to programmatically change the value of this color. I don't want to have to update every object's color individually. I have tried this:
<Grid
Background="{Binding GalleryViewBrush, Mode=TwoWay}"
Grid.Row="0"
Grid.Column="0">
Then in codebehind:
public Brush GalleryViewBrush { get; set; }
GalleryViewBrush = new SolidColorBrush(Colors.Red);
But the color never works. I have tried xbind too but no luck
thanks
Your view model needs to implement
INotifyPropertyChanged
, and then fire thePropertyChanged
event when your brush property changes. Conventionally that's done in the setter for the property.If your get/set for
GalleryViewBrush
in your question is what's actually in the code sample in your question, that's likely to be the issue.Mind typos in my code sample above, I'm hammered ATM.