我有一个列表框,其中的项目模板在XAML中定义如下:
<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>
现在我想要的是,在列表框的项目源为空的情况下,在列表框中心显示一行文本。
XAML是否支持某种无项目模板?就像这样:
<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>
所以呢?