user3257435
user3257435

Reputation: 103

Display default on page when list is empty in windows phone 8

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

Answers (1)

Dean Chalk
Dean Chalk

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

Related Questions