Visualtreehelper of WPF ComboBox

Source: Internet
Author: User

Textchanged is required when you use the ComboBox control of WPF, but this property belongs to the Textbox Control. You don't have to worry about it. There is a textbox in ComboBox, so the key issue is how to find the Textbox Control in ComboBox.

Default ComboBox control composition:

The first layer (1 Control ):

System. Windows. Controls. Grid

Layer 2 (2 controls ):

System. Windows. Controls. primitives. Popup;

Microsoft. Windows. Themes. listboxchrome;

System. Windows. Controls. textbox;

System. Windows. Controls. primitives. togglebutton content: ischecked: false

Controls are arranged in order, so the Textbox Control is obtained as follows:

 
(Textbox) visualtreehelper. getchild (visualtreehelper. getchild (this. cbserver, 0), 2). textchanged + = new textchangedeventhandler (setdatabaseisenabled );

Note:CodeTo be placed in the window_loaded () event, it cannot be placed in the page constructor.

You can add the textchanged attribute to the ComboBox control.

PS: Find the code of the control in ComboBox:

 
Private void button#click (Object sender, routedeventargs e) {for (INT I = 0; I <visualtreehelper. getchildrencount (this. cbserver); I ++) {dependencyobject O1 = visualtreehelper. getchild (this. cbserver, I); For (Int J = 0; j <visualtreehelper. getchildrencount (O1); j ++) {dependencyobject O2 = visualtreehelper. getchild (O1, j );}}}

 

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.