I have a list box with an item template defined in XAML like this:
<ListBox Name="listBoxDisruptions">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<TextBlock Text="{Binding text}" Foreground="Black" FontSize="29">Hello! some item</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Now what i want is to display a line of text in the center of the listbox in case the ItemSource for this listbox is empty.
Does XAML support some kind of no item template, ? something like this:
<ListBox Name="listBoxDisruptions">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<TextBlock Text="{Binding text}" Foreground="Black" FontSize="29">Hello! some item</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.NoItemTemplate>
<TextBlock Text="No Items to display"/>
</ListBox.NoItemTemplate>
</ListBox>
So ?
There might be a XAML way to do it using WPF-like techniques – Listbox Item Template for an empty list
However, in Overflow7 I got bored trying to make these work – so I used a slightly-hacky trick instead of adding an extra TextBlock to the page and then using:
(Trick learnt from http://forums.create.msdn.com/forums/p/70755/431687.aspx)