WPF uses label extension to assign values to attributes of an object.

Source: Internet
Author: User
1. Use tag extension to assign values to attributes of an object.

 

CodeAs follows:

Textblock 1   < Window. Resources >
2 < SYS: String X: Key = " Hellostring " > Hellostring </ SYS: String >
3
4 </ Window. Resources >
5 < Grid >
6 < Textblock height = " 20 " Width = " 300 " Text = " {Staticresource resourcekey = hellostring} " />
7
8 </ Grid >

 

3. dynamically bind the extension tag

The textbox value changes as the slider slides.

 

The Code is as follows:

Binding 1   < Grid >
2 < Grid. rowdefinitions >
3 < Rowdefinition height = " 33 " > </ Rowdefinition >
4 < Rowdefinition height = " 4 " > </ Rowdefinition >
5 < Rowdefinition height = " 30 " > </ Rowdefinition >
6 </ Grid. rowdefinitions >
7 < Textbox X: Name = " TB " Text = " {Binding elementname = SLD, Path = value} "   > </ Textbox >
8 < Slider X: Name = " SLD " Grid. Row = " 2 " Value = " 50 " Maximum = " 100 " Minimum = " 0 " > </ Slider >
9 </ Grid >

 

 

Reference: WPF extension labels

 

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.