zoukankan      html  css  js  c++  java
  • Silverlight使用笔记

    1. ItemsSource绑定写法,此写法可为一个页面绑定多个对象
      ItemsSource
    ="{Binding QuoteItems, Source={StaticResource QIViewModel}}"

    2. Style需合并到App.xaml
      Style合并
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Style.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    
    
    3. INotifyPropertyChanged
      
    虽然看过INotifyPropertyChanged的相关资料,但其实一直没搞清楚他的真正作用,做了个测试,请看下面的代码,Product类有Id和Name属性。
      [1] Name属性注释掉RaisePropertyChanged(new PropertyChangedEventArgs("Name")),可以得到Name的值,这点说明只要类的属性与控件binding,那么就可以获取到在页面输入的值。
      [2] 我们在页面放置两个控件:textbox,textblock,并将text都绑定为product的name属性,在textbox中输入的name值没有反应到textblock上的,
    去掉
    注释,textblock的文本跟随改变,这说明INotifyPropertyChanged的作用是:通知UI更新数据
      Product
    public class Product : INotifyDataErrorInfo, INotifyPropertyChanged
        {
            public Product()
            {
            }
    
            private int idValue;
            public int Id
            {
                get { return idValue; }
                set
                {
                    if (IsIdValid(value) && idValue != value)
                    {
                        idValue = value;
                        RaisePropertyChanged(new PropertyChangedEventArgs("Id"));
                    }
                }
            }
    
            private string nameValue;
            public string Name
            {
                get { return nameValue; }
                set
                {
                    if (IsNameValid(value) && nameValue != value)
                    {
                        nameValue = value;
                    }
                    //RaisePropertyChanged(new PropertyChangedEventArgs("Name"));
                }
            }
            //以下代码省略
    }
    
    
  • 相关阅读:
    61031145 ERROR
    插入IO寄存器和位置约束---lattice&diamond
    lattice简单时序报告---timing report
    自动化仿真模型的搭建---基于lattice DO文件和modelsim脚本
    IIC加载以及存在的问题---lattice XO3
    DUALBOOT(双启动) 调试
    jtag管脚复用---lattice LCMXO3
    flask学习笔记-10:留言板(三)
    #flask学习笔记-09:留言板(二)
    #flask学习笔记-08:留言板(一)
  • 原文地址:https://www.cnblogs.com/luhe/p/2737351.html
Copyright © 2011-2022 走看看