How do you color a rectangle in C# that has been declared in XAML in WPF?
There is a rectangle control in XAML. In my C# code there are times in which it would be n
Wpf binding would be able to do this without having to reference the control by name in code:
Then put a property on your DataContext class, assuming you have implemented INotifyPropertyChanged:
public Brush FillColor
{
get { return this.fillColor; }
set
{
this.fillColor = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Then you can assign your required color to the FillColor property and the UI will update itself.