[Common Considerations for WPF series]-treeview

Source: Internet
Author: User

Introduction

Projects often use the TreeView to organize some hierarchical data, and this section summarizes the projects using the common questions in the TreeView.

DataBinding Data Binding

DataTemplate Custom
<hierarchicaldatatemplateDataType="{x:type Viewmodels:fieldviewmodel}"ItemsSource="{Binding Subviewmodels}">                    <StackPanelOrientation= "Horizontal">                        <TextBlockText= "F:"Style="{StaticResource Icontextstyle}"Background= "Lightcoral"/>                        <TextBlockText="{Binding CurrentEntity.Value.Name}"Focusable= "True">                            <Textblock.contextmenu>                                <ContextMenu>                                    <MenuItemHeader= "New Well"Command="{Binding AddCommand}"CommandParameter="{Binding Path=currententity.value}" />                                    <MenuItemHeader= "Delete"Command="{Binding DeleteCommand}"CommandParameter="{Binding Path=currententity.value}" />                                </ContextMenu>                            </Textblock.contextmenu>                        </TextBlock>                    </StackPanel>                </hierarchicaldatatemplate>
Style customization

Events Order

Selecteditemchanged occurs in the TreeView to the new SelectedItem focus (set focus on its new selected item).

Bottom line: Selecteditemchanged–>set Foucs on the new selected item.

From: https://social.msdn.microsoft.com/Forums/en-US/e41ec0e1-f63e-40a3-bfea-1d61d0cfcf1e/ Set-focus-on-textbox-after-click-on-treeviewselecteditemchanged?forum=wpf&prof=required

[Common Considerations for WPF series]-treeview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.