MarkUpExtension In WPF

MarkUpExtension

MarkupExtension resolves value of a property at the runtime. These are dynamic placeholders for attribute values in XAML. They are surrounded by curly braces (i.e {}) like StaticResource NormalBackgorundBrush}”.

The first identifier within a pair of curly braces is the name of the extension. 

Some built-in MarkUpExtension are given below.

  • Binding - For binding the values of two properties.
  • TemplateBinding - For binding a control template to dependency property of control.
  • DynamicResource - For auto updating lookup of the resource entry.
  • StaticResoure - For one time lookup of the resource entry.
  • X:Null - For returning null.
  • X:Static - For resolving value of static property.

Example 

  1. <textbox x:Name=”txtBox”/>  
  2. <Lable Content =”{Binind Text, ElementName=txtBox}”/>  

Now, if you type text into textbox, as the text property changes, the binding mark up extension automatically updates the content of the label.

Next Recommended Reading Popup Example in WPF