title: WPF change ItemsPanel and ItemTemplate in code behind
body: <p>I have the following list in XAML:</p>
  
  <pre><code>&lt;ListView Name="ListViewBack"
            Margin="3"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ItemsPanel="{StaticResource IconListPanelTemplate}"
            ItemTemplate="{StaticResource IconListDataTemplate}"&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>Now I would like to be able to change the ItemsPanel and ItemTemplate from the List to the Grid version. I've tried this using the following code:</p>
  
  <pre><code>ListViewBack.ItemsPanel = Resources["IconGridPanelTemplate"] as ItemsPanelTemplate;
  ListViewBack.ItemTemplate = Resources["IconGridDataTemplate"] as DataTemplate;
  </code></pre>
  
  <p>But nothing happens when excecuted.</p>
  
  <p>Any idea's?</p>
  
  <p>Thanks!</p>