Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing multiple Treeview objects with the same (but cloned) itemssource
    primarykey
    data
    text
    <p>So, I have a <code>listview</code> with different <code>datatemplates</code> as seen here:</p> <pre><code>&lt;ListView Panel.ZIndex="0" x:Name="FilterList" Margin="10,0" Grid.Row="2" Grid.ColumnSpan="3" Background="White" ItemTemplateSelector="{StaticResource ReportFilterTemplateSelector}" ItemsSource="{Binding reportParameters, Mode=TwoWay}" ScrollViewer.CanContentScroll="False"&gt; </code></pre> <p>One of my sample <code>datatemplates</code> can be seen below. Everything shows up great. My problem, is that for this (and other) <code>datatemplates</code>, I can have multiple instances of the same one. In this particular instance, the <code>treeview</code> <code>itemssource</code> is bound to <code>DataContext.OfficeListText</code> to populate all the elements.</p> <pre><code> &lt;DataTemplate x:Key="office"&gt; &lt;Grid MinHeight="35" MaxHeight="250"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="100"/&gt; &lt;ColumnDefinition/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Text="{Binding rpName}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" /&gt; &lt;Expander HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="1" Header="{Binding Path=DataContext.OfficeListText, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" VerticalAlignment="Top" ExpandDirection="Down"&gt; &lt;TreeView Tag="{Binding rpParameter}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Path=DataContext.OfficeList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}" ItemTemplate="{StaticResource CheckBoxItemTemplate}" ItemContainerStyle="{StaticResource TreeViewItemStyle}"/&gt; &lt;/Expander&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; </code></pre> <p>The main problem with this is one, for instance, if I select an office in say the first <code>treeview</code>, the 2nd <code>treeview</code> shows the same. Essentially I want them to have the same itemssource initially but have separate instances. Since they are generated dynamically that is where I'm getting stuck. Any help would be appreciated. </p> <p>I'm not sure what other code would be necessary, since I'm sure most of it will be irreverent based on what I'll need to do to make this work, but if you would like more I will gladly provide. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload