I have a TreeView control from System.Windows.Controls on MainPage.
<controls:TreeView x:Name="Tree"
SelectedItemChanged="Tree_SelectedItemChanged" />
MainPage ctor looks like this:
public MainPage()
{
InitializeComponent();
for (int i = 0; i < 10; ++i)
Tree.Items.Add(new TreeViewItem() { Header = i.ToString() } );
(Tree.Items[0] as TreeViewItem).IsSelected = true;
}
Just fill TreeView and select first element.
In Tree_SelectedItemChanged I want to do some action with selection item, but Tree.SelectedItem has a null value.
I don't understand why it happens. TreeView in Wpf works fine.
Have you any ideas about it?