Windows 8 Store Apps Learning (52) binding

Source: Internet
Author: User
Tags bind expression xmlns

Binding: Binding with Element Model Indexer Style RelativeSource, and data conversion in bindings

Introduced

Re-imagine the bindings of Windows 8 Store Apps

Binding with Element

With Model binding

Binding with Indexer

Bind a Setter in a Style (bind a static Resource)

Application of an extended tag RelativeSource for Binding

Data transformations in Bindings

Example

1, demonstrates how to bind with the Element, and onetime, oneway, TwoWay difference

Binding/bindingelement.xaml

<page x:class= "XamlDemo.Binding.BindingElement" xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentat Ion "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" using:XamlDemo.Binding "xmlns:d=" http ://schemas.microsoft.com/expression/blend/2008 "xmlns:mc=" http://schemas.openxmlformats.org/ markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" Transparent "> <stackpanel  margin= "0 0 0" > <!--This example demonstrates how to bind to the Element, as well as onetime, OneWay, TwoWay
            The difference between--> <!--onetime way binding elements-->
            <slider name= "Slideronetime" minimum= "1" maximum= "ten" value= "" width= "180" horizontalalignment= "left"/> <textbox text= "{Binding elementname=slideronetime, path=value, mode=onetime}" width= "" horizontalalignment= "Le FT "/> <!--ONeway binding elements (OneWay is the default)--> <slider name= "Slideroneway" minimum= "1" maximum= "value=" "Width=" 180 "horizontalalignment=" left "margin=" 0 0 0 "/> <textbox text=" {Binding elementname=slid
                Eroneway, Path=value, Mode=oneway} "width=" horizontalalignment= "left"/> <!-- TwoWay method Binding element--> <slider name= "Slidertwoway" minimum= "1" maximum= "value=" "width=" 18 0 "horizontalalignment=" left "margin=" 0 0 0 "/> <textbox text=" {Binding elementname=slidertwoway, Pat H=value, Mode=twoway} "width=" horizontalalignment= "left"/> </StackPanel> </Grid> ;/page>

2, how to demonstrate with the Model for two-way binding

Binding/bindingmodel.xaml

<page x:class= "XamlDemo.Binding.BindingModel" xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentatio N "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" using:XamlDemo.Binding "xmlns:d=" http:/ /schemas.microsoft.com/expression/blend/2008 "xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/ 2006 "mc:ignorable=" D "> <grid background=" Transparent "> <stackpanel margin=" 0 0 0 "Na
                
            Me= "root" > <textblock name= "lblmsg" fontsize= "14.667"/> <textbox fontsize= "14.667" text= "{Binding path=name, mode=twoway}" margin= "0 0"/> <textbox F Ontsize= "14.667" text= "{Binding age, Mode=twoway}" margin= "0 ten 0"/> <toggleswitch offcontent= "female" on content= "Male" header= "gender" margin= "0 0" > <ToggleSwitch.IsOn> <binding P Ath= "Ismale" mode= "TwoWay"/>
                </ToggleSwitch.IsOn> </ToggleSwitch> </StackPanel> </Grid> </Page>

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.