Note that there are some explanatory texts on larger screens.

plurals
  1. POTreeview Item Loses Selection When Focus Is Lost
    text
    copied!<p>I have noticed this on an application I am working on right now, so I created a simple test app to demonstrate. Below is my a window and the event handler for the treeview items. If you expand either the "One" or "Two" parent nodes, and click one of the children, the child that was selected does not show up as selected after the Focus() method is called on the text box. Instead, selection pops to the parent node. Does anyone have any idea how to overcome this, and have the selection remain with the selected child node? Thanks.</p> <pre><code>&lt;Window x:Class="DockingSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" WindowState="Maximized" &gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="300" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TreeView Margin="6"&gt; &lt;TreeViewItem Header="One"&gt; &lt;TreeViewItem Header="One" Selected="TreeViewItem_Selected" /&gt; &lt;TreeViewItem Header="Two" Selected="TreeViewItem_Selected" /&gt; &lt;TreeViewItem Header="Three" Selected="TreeViewItem_Selected" /&gt; &lt;/TreeViewItem&gt; &lt;TreeViewItem Header="Two"&gt; &lt;TreeViewItem Header="One" Selected="TreeViewItem_Selected" /&gt; &lt;TreeViewItem Header="Two" Selected="TreeViewItem_Selected" /&gt; &lt;TreeViewItem Header="Three" Selected="TreeViewItem_Selected" /&gt; &lt;/TreeViewItem&gt; &lt;/TreeView&gt; &lt;TextBox Grid.Column="1" x:Name="textbox" /&gt; &lt;/Grid&gt; </code></pre> <p></p> <pre><code>private void TreeViewItem_Selected(object sender, RoutedEventArgs e) { textbox.Focus(); } </code></pre> <p>With the above window and the "Selected" event handl</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