tags:

views:

28

answers:

1

I need to display search results in the Grid format. But when the Search results in zero matches, i should be able to show a message "0 results found" in the second row of the Grid with first row having all the column headers.

Which control can i use in the WPF to achieve this? There are ways to do this without header row, but i need to display the Column Header with the message in the data rows.

A: 

Use the same approach as the question you mention, but keep the list visible.

<ContentPresenter Content="{Binding}">
    <ContentPresenter.ContentTemplate>
        <DataTemplate>
            <Grid>
                <ListView Name="list" ItemsSource="{Binding MyList}"/>
                <TextBlock Name="empty" Text="No items found" Visibility="Collapsed"/>
            </Grid>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding MyList.Count}" Value="0">
                    <Setter TargetName="empty" Property="Visibility" Value="Visible"/>
                </DataTrigger>                        
            </DataTemplate.Triggers>
        </DataTemplate>
    </ContentPresenter.ContentTemplate>
</ContentPresenter>

Too simple? Am I missing something?

Eduardo Molteni
Will this work if 'Count' is not a dependency property?
YotaXP