Change ItemTemplate of XAML Listview programmatically in backend
<p>I've read so many postings here on StackOverflow and lots of blog entries but could not find a working answer to my question:
I'm developing a windows 10 universal app. I have a listview using an item template. Now I added another item template and want to set with template to use when the application starts. No need to do it item by item, the template should be added for all items.</p>

<pre><code>&lt;Page.Resources&gt;
    &lt;DataTemplate x:Key="DataTemplate1"&gt;
        (...)
    &lt;/DataTemplate&gt;
    &lt;DataTemplate x:Key="DataTemplate2"&gt;
        (...)
    &lt;/DataTemplate&gt;

&lt;/Page.Resources&gt;

&lt;ListView
        x:Name="itemListView"
        AutomationProperties.AutomationId="ItemsListView"
        AutomationProperties.Name="Items"
        TabIndex="1"
        Grid.Column="0"
        IsSwipeEnabled="False" HorizontalContentAlignment="Stretch"
        SelectionChanged="ItemListView_SelectionChanged" IsSynchronizedWithCurrentItem="False" 
        ItemsSource="{Binding FeedItems}" ItemTemplate="{StaticResource DataTemplate1}" Margin="0,60,0,10" Grid.RowSpan="2"&gt;
        &lt;ListView.ItemContainerStyle&gt;
            &lt;Style TargetType="ListViewItem"&gt;
                &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"&gt;&lt;/Setter&gt;
            &lt;/Style&gt;
        &lt;/ListView.ItemContainerStyle&gt;
    &lt;/ListView&gt;
</code></pre>

<p>What's the easiest way to do it? I've tried so many options, none of them did work :-(
Many thanks!</p>