wpf - Fill color from property via XAML -


i learning wpf , have simple question.
how set fill color 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 backgroundcolor.           /// </summary>    public solidcolorbrush backgroundcolorf    {        get;        set;    }     public mainwindow()    {        this.initializecomponent();        backgroundcolorf =  new solidcolorbrush(colors.red);     } } 

set datacontext this

public mainwindow()    {        this.datacontext = this;              this.initializecomponent();        backgroundcolorf =  new solidcolorbrush(colors.red);     } 

this should work.but there little more done making wpf app scalable notifications,dependency properties etc.i recommend go through basics of wpf databinding architecture before continuing.go through link posted h.b in comments


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -