Skip to content

Instantly share code, notes, and snippets.

@julesx
Created December 17, 2013 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julesx/8012494 to your computer and use it in GitHub Desktop.
Save julesx/8012494 to your computer and use it in GitHub Desktop.
<Window x:Class="WpfApplication16.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="ListBox" x:Key="ListStyle" BasedOn="{StaticResource {x:Type ListBox}}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<TextBlock>No items to display</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
<ControlTemplate x:Key="NoScroll">
<ItemsPresenter />
</ControlTemplate>
</Window.Resources>
<Grid>
<ListBox Style="{StaticResource ListStyle}" Template="{StaticResource NoScroll}">
</ListBox>
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment