zoukankan      html  css  js  c++  java
  • SL4.数据绑定OneWay、OneTime、TwoWay

    XAML:

               <Button Name="MyButton" Content="Update"  Click="MyButton_Click"  Width="65" Height="41"></Button>
    <TextBlock Height="23" Name="tbtitle" Text="{Binding Title,Mode=OneTime}" />
    <TextBlock Height="23" Name="tbtitles" Text="{Binding Title,Mode=OneWay}" />
    <TextBlock Height="23" Name="tbprice" Text="{Binding Price,Mode=TwoWay}" />

      

    XAML.CS:

           public partial class MainPage : UserControl
    {
    Book book
    = new Book();
    public MainPage()
    {
    InitializeComponent();
    book.Title
    = "CCTV-5频道";
    book.Price
    = 12;
    tbtitles.DataContext
    = book;
    tbtitle.DataContext
    = book;
    tbprice.DataContext
    = book;
    }

    private void MyButton_Click(object sender, RoutedEventArgs e)
    {
    book.Price
    = 44;
    book.Title
    = "中华电台-5频道";
    }

      

    Bool.CS:
     

        public class Book : INotifyPropertyChanged
    {
    public event PropertyChangedEventHandler PropertyChanged;
    private string _Title;
    public string Title
    {
    get { return _Title; }
    set
    {
    _Title
    =value;
    if (PropertyChanged != null)
    {
    PropertyChanged(
    this, new PropertyChangedEventArgs("Title"));
    }
    }
    }
    private decimal _price;
    public decimal Price
    {
    get
    {
    return _price;
    }
    set
    {
    _price
    = value;
    if (PropertyChanged != null)
    {
    PropertyChanged(
    this, new PropertyChangedEventArgs("Price"));
    }
    }
    }
    }

      

    代码很简单,重点在于实体类要实现INotifyPropertyChanged


  • 相关阅读:
    zuul prefix
    zuul忽略表达式
    zuul 自定义路由映射规则
    ribbon重试机制
    feign容断忽略某些异常
    cloud turbine
    hystrix 给方法加断路器
    go语言常用函数:cap
    windows 安装 go语言
    mysql win源码比较大 不需要的文件删除 记录下来
  • 原文地址:https://www.cnblogs.com/baobao2010/p/2152067.html
Copyright © 2011-2022 走看看