Data is at the heart of virtually any business application.  WPF ships with a flexible data binding engine that simplifies writing data centric applications.  I spend a lot of time during my WPF class talking about this data-binding feature.  In fact I devote three sections during the week to this topic.

image

Last week I added a new binding demo to the Data Templates chapter.  The idea is to bind a <MenuItem > header property to the contents of an XML file.  Changing the XML file contents results in updates to the menu structure.

 

<XmlDataProvider x:Key="menuKey"
                   Source="../menu.xml"
                   XPath="menus" />
 
  <Style x:Key="itemStyle">
    <Setter Property="MenuItem.Header" Value="{Binding XPath=@header}"/>
  </Style>
  <Style x:Key="categoryStyle">
    <Setter Property="MenuItem.Header" Value="{Binding XPath=@categoryName}"/>
    <Setter Property="MenuItem.ItemsSource" Value="{Binding XPath=menu}"/>
    <Setter Property="MenuItem.ItemContainerStyle" Value="{StaticResource itemStyle}"/>
  </Style>

You can see this demo and many other data demos during my 2 day WPF virtual class  on March 23-24.