I am learning WPF and have this simple question.
How do I set fill color to property vi XAML?
<Rectangle Fill="{Binding Path=BackgroundColorf}"
Height="112" Margin="0,84,0,0" VerticalAlignment="Top"
Width="116"/>
public partial class MainWindow : Window
{
/// <summary>
/// Gets or sets the BackgroundColor.
/// </summary>
public SolidColorBrush BackgroundColorf
{
get;
set;
}
public MainWindow()
{
this.InitializeComponent();
BackgroundColorf = new SolidColorBrush(Colors.Red);
}
}
Set the datacontext like this
This should work.But there is little more to be done for making your wpf app scalable like Notifications,Dependency properties etc.I recommend you go through the basics of wpf DataBinding architecture before continuing.Go through the link posted by H.B in the comments