Reputation: 103
I am trying to display a default message on page when list is empty.
<phone:PivotItem>
<phone:PivotItem.Header>
</phone:PivotItem.Header>
<ScrollViewer>
<ItemsControl ItemsSource="{Binding collection}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:ProcessRequest URLSource="{Binding Title}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
I don't want to go in View Model to check whether list empty, then change the visibility of text block with message.
Is there any way to implement a generic method?
Upvotes: 0
Views: 180
Reputation: 20471
Change the Visibility
of a TextBox
by binding its Visibility
property to the collection.Count
property, and use a custom IValueConverter
to switch Visibility
depending on the count. This means your viewmodel isn't involved.
Upvotes: 1