Binding windows phone7 themes, styles, and data

Source: Internet
Author: User
  • User-defined themes

    • For example, you can select a bright or gloomy background.
    • There are 10 subject colors available (accent colors)
  • Silverlight automatically detects a topic.
    • ApplicationProgramAutomatically apply the selected topic
    • Developers can customize specific controls and cover theme Solutions
  • For the style of the Silverlight control, we can see a figure:

    The red part is the legendary style, and the specific style definition is

    One themeresources. XAML in such a path defines the template of the Silverlight for Windows Phone standard control in another file system. Windows. XAML in the same directory.

  • Data Binding

          • Data Binding provides a simple way of data presentation and interaction for the Silverlight program, so that the presentation and program logic are separated.
          • Once a binding relationship is established, the UI and Data Objects can automatically synchronize data.
          • Binding method:

            The following is an example from Mr Lin Yongjian. The text size of textblock is changed by sliding the silder control. The fontsize attribute of textblock is found.

          • After binding application data, another selection dialog box is displayed.

            Select slider1, and select value for path. A simple binding is completed. The fontsize of the bound element is bound to the value of the slider. The data binding mode is onetime.

          • There are three data binding modes:

            • The property of the one time target control is updated only once and will be ignored later.
            • The value of the one way data object will be synchronized to the properties of the target control, but the changes to the properties of the target control will not be updated to the data object.
            • The properties of the target two way control and the values of data objects are updated with each other.
          • Data Objects bound to one way and two way must be inherited from inotifypropertychanger
      • The above data binding is bound to a UI element, not to say that it can only be bound to the UI, because it can be bound to all CLR crosstalk lines, we can also bind it to a custom class. First, create a postcodeclass. Because we need to use the two-way binding mode, we need to inherit the excuse. Inotifypropertychanged
        Using system; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. ink; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using system. componentmodel; namespace postcodemanager {public class postcodeclass: inotifypropertychanged {public event propertychangedeventhandl Er propertychanged; private int postcode; Public int postcode {get {return postcode;} set {postcode = value; address = postcodequery. instance. getaddressbypostcode (postcode); If (propertychanged! = NULL) {propertychanged. invoke (this, new propertychangedeventargs ("Address") ;}} Public String address = ""; Public String address {get {return address ;} set {address = value ;}}}}

        After the class is defined, it is used in the XAML file. The first step is to add a namespace and then introduce this class as a static resource, for example:

    You can use it as follows:

    In the first red box, the text attribute of textblock is bound to the postcode attribute of postcodeclass, and mode = twoway. The text attribute of the second textblock is bound to the address attribute of postcodeclass, this means that when the text of this textblock changes, it will automatically synchronize the changes to its data object, and the data object will update the address to the second textblock;

     

Source code download

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.