Note that there are some explanatory texts on larger screens.

plurals
  1. POItems not showing in WPF ListBox even though they show up in design mode
    primarykey
    data
    text
    <p>I'm having some problems with data binding in XAML and WPF. Specifically, I'm trying to bind data from an XmlDataProvider to a ListBox.</p> <p>The problem is this, when I'm in design mode in Visual Studio 2010, the xml items show up correctly, but when I run the app the listbox is just empty.</p> <p>Here is what my xaml looks like. I'm not using any code behind, so this is all there is:</p> <pre><code>&lt;Window x:Class="WpfTest9_Binding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="309" Width="622"&gt; &lt;Window.DataContext&gt; &lt;XmlDataProvider XPath="Servers"&gt; &lt;x:XData&gt; &lt;Servers&gt; &lt;Server name="Server01" active="true" /&gt; &lt;Server name="Server02" active="false" /&gt; &lt;Server name="Testserver01" active="true" /&gt; &lt;Server name="Testserver02" active="true" /&gt; &lt;/Servers&gt; &lt;/x:XData&gt; &lt;/XmlDataProvider&gt; &lt;/Window.DataContext&gt; &lt;Grid&gt; &lt;ListBox ItemsSource="{Binding XPath=*}" Margin="12"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Border CornerRadius="5" Margin="5" BorderThickness="2" BorderBrush="#FFC14343"&gt; &lt;StackPanel Orientation="Horizontal" Margin="5"&gt; &lt;CheckBox IsChecked="{Binding XPath=@active}" /&gt; &lt;Label Content="{Binding XPath=@name}" /&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Like I said above, the strange thing is that it looks like it's working while in design mode, but it fails to fill the listbox when I run the application. I'm not getting any error messages or warnings either.</p> <p>What's wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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