Hello! I have a WPF paging application that navigates to a side menu based on a TreeView. Each TreeViewItem.Tag contains a frame bound to the page. I give a fragment of markup:

<TreeView x:Name="tvSections" Margin="0,0,0,0" Grid.ColumnSpan="2" Background="LightSteelBlue" BorderBrush="{x:Null}" > <TreeViewItem Header="Главная форма" IsSelected="True" IsExpanded="True" Cursor="Hand" FontSize="16"> <TreeViewItem.Tag> <Frame Name="frame16" Margin="0,0,0,0" Source="Page_void.xaml" /> </TreeViewItem.Tag> <TreeViewItem Header="Клиенты" IsExpanded="True" Cursor="Hand" FontSize="16" > // тут проблема <TreeViewItem.Tag> <Frame Name="frame17" Margin="0,0,0,0" Source="Page2.xaml" /> </TreeViewItem.Tag> <TreeViewItem Header="Данные" Cursor="Hand"> <TreeViewItem.Tag> <Frame Name="frame2" Margin="0,0,0,0" Source="Page2.xaml" /> </TreeViewItem.Tag> </TreeViewItem> <TreeViewItem Header="Записи" Cursor="Hand"> <TreeViewItem.Tag> <Frame Name="frame7" Margin="0,0,0,0" Source="Page7.xaml" /> </TreeViewItem.Tag> </TreeViewItem> </TreeViewItem> <TreeViewItem Header="Договора" IsExpanded="True" Cursor="Hand" FontSize="16" > <TreeViewItem.Tag> <Frame Name="frame18" Margin="0,0,0,0" Source="Page10.xaml" />// и тут проблема </TreeViewItem.Tag> <TreeViewItem Header="Абонементы" Cursor="Hand"> <TreeViewItem.Tag> <Frame Name="frame10" Margin="0,0,0,0" Source="Page10.xaml" /> </TreeViewItem.Tag> </TreeViewItem> <TreeViewItem Header="Услуги" Cursor="Hand"> <TreeViewItem.Tag> <Frame Name="frame9" Margin="0,0,0,0" Source="Page9.xaml" /> </TreeViewItem.Tag> </TreeViewItem> </TreeViewItem> 

It is necessary to make it so that when a user clicks on tree nodes (Clients, Contracts), they will expand / collapse, but the displayed page will remain the same. When you select the remaining TreeViewItem, the page should change to the specified Frame bound to it. Now in problem areas I have attached pages, because without them the window tvSections area becomes completely empty. Is it possible to realize the conceived plan and how to do it?

  • Is it possible to remove unnecessary from the markup? For example, the colors are clearly not needed to clarify the essence of the issue. - VladD

1 answer 1

Subscribe to the deployment event handling and set e.Handled = true;