Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think that in your case the best way to achieve this is to get the scroll viewer inside the tree view completely out of the way by creating a bare-bones tree view style like this:</p> <pre><code> &lt;Style x:Key="TreeViewStyle1" TargetType="sdk:TreeView"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="sdk:TreeView"&gt; &lt;Grid&gt; &lt;ItemsPresenter Margin="5,5,19,19" d:LayoutOverrides="Width, Height"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Then simply apply the template to your scroll viewer and wrap it up with an external scroll viewer, this way:</p> <pre><code>&lt;Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource TreeViewSampleData}}"&gt; &lt;ScrollViewer&gt; &lt;sdk:TreeView ItemsSource="{Binding RootCollection}" ItemTemplate="{StaticResource FirstLevelTemplate}" Style="{StaticResource TreeViewStyle1}"/&gt; &lt;/ScrollViewer&gt; &lt;/Grid&gt; </code></pre> <p>Now the tree view has no way to communicate with the scroll viewer and therefore it won't be able to scroll when an item is selected.</p> <p>Keep in mind that this eliminates any automatic scrolling and only manual scrolling is now possible. You can still add your own automatic scrolling by using behaviors or TargetedTriggerAction(s).</p> <p>Make sure not to set any sizes on the tree view, so that it grows freely inside the scroll viewer.</p> <p>I hope this helps.</p>
 

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