Display some text when binded listview has no items Display some text when binded listview has no items wpf wpf

Display some text when binded listview has no items


The trick is in overriding ListView's template. When there are no items in ListView you should set your ControlTemplate with TextBlock:

<ListView Name="List" ItemsSource="{Binding Items}">    <ListView.Style>        <Style TargetType="ListView">            <Style.Triggers>                <Trigger Property="HasItems"                         Value="False">                    <Setter Property="Template">                        <Setter.Value>                            <ControlTemplate TargetType="ListView">                                <TextBlock Text="No items..."/>                            </ControlTemplate>                        </Setter.Value>                    </Setter>                </Trigger>            </Style.Triggers>        </Style>    </ListView.Style></ListView>


The ListView itself does not supply this functionality. The simplest approach is to place a TextBlock in front of the ListView with its Visibility set to Collapsed. You can then make it Visible when your list has no items in it.

If you need help with the specific, please expand your question.