1

I have a ListView, with ListViewItem s being properly formatted using ItemTemplateSelector when the control first loads content. The data is properly coded using INotifyPropertyChanged.

My question is: How do I cause a single ListViewItem to update it's DataTemplate after the ListView has already loaded the data? I'm not sure if I need to use a setter or a task or a simple binding. Has anyone done this already?

My ListView code:

        <ListView x:Name="lv_src_gStream" 
                  ItemsSource="{Binding Source={StaticResource CVS_src_gStream}}" 
                  PointerPressed="selectPost" 
                  SelectionMode="None" 
                  HorizontalContentAlignment="Stretch" 
                  ItemTemplateSelector="{StaticResource postTemplateSelector}">
        </ListView>

This works well when the data first loads, but when a variable changes, how do I get the ItemTemplateSelector to choose a different template?

Ken Cone
  • 460
  • 1
  • 4
  • 11

1 Answers1

0

I don't think you can change single ListViewItem template dynamically after loaded. But you can use ItemContainerStyle to custom your template on specific event, like Unfocused, Selected, Pressed... Here is a sample How do I set a different background colour on item click of ListView for metro/WinRT app?

Community
  • 1
  • 1
Nicky Liu
  • 165
  • 2
  • 13