Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Data bindings are tough because they tend to fail silently, which makes them very hard to debug. The number one issue that you had in your code was a misspelling of the ElementName on the lbFiles ListBox. Misspellings will get you every time! I was able to get the File names to appear after correcting the spelling mistake, removing the innerText portion of the binding, and removing the ItemTemplate. I'm not sure why the ItemTemplate wasn't working, but hopefully this example will get you moving again.</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="600" Width="800"&gt; &lt;Window.Resources&gt; &lt;XmlDataProvider x:Key="AllDeployments" XPath="Deployments" Source="Deployments.xml" /&gt; &lt;DataTemplate x:Key="dtDeployments"&gt; &lt;StackPanel FlowDirection="LeftToRight" Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding XPath=@Name}" /&gt; &lt;TextBlock Text=" - "/&gt; &lt;TextBlock Text="{Binding XPath=@Date}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;DataTemplate x:Key="dtFiles"&gt; &lt;TextBlock Text="{Binding XPath=File}" /&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;Grid Name="gMain"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition Width="2"/&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Menu Grid.Column="0" Grid.ColumnSpan="3"&gt;&lt;/Menu&gt; &lt;ListBox Grid.Column="0" Name="lbDeployment" ItemsSource="{Binding Source={StaticResource AllDeployments}, XPath=Deployment}" ItemTemplate="{StaticResource dtDeployments}"&gt;&lt;/ListBox&gt; &lt;GridSplitter Grid.Column="1"&gt;&lt;/GridSplitter&gt; &lt;StackPanel Grid.Column="2"&gt; &lt;ListBox Name="lbFiles" ItemsSource="{Binding ElementName=lbDeployment, Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}" Height="400" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload