zoukankan      html  css  js  c++  java
  • WPF绑定方式

     数据绑定的方式:                                                                             (1)、OneWay,单一方向的绑定,只有在数据源发生变化后才会更新绑定目标。                             (2)、TwoWay,双向绑定,绑定的两端任何一端发生变化,都将通知另一端。                             (3)、OneTime,只绑定一次。绑定完成后任何一端的变化都不会通知对方。

    例如: <TextBox OpacityMask="AliceBlue" Text="{Binding Titile,Mode=OneWay}"  >
            </TextBox>

         <TextBox OpacityMask="AliceBlue" Text="{Binding Titile,Mode=TwoWay}"  >
            </TextBox>

         <TextBox OpacityMask="AliceBlue" Text="{Binding Titile,Mode=OneTime}"  >
            </TextBox>

     目前,指定数据源有三种方式,我们可以通过任何一种方式来指定上述的任何一种数据源: 
    (1)、通过Source标记。我们可以在使用Binding使用Source标记显式指定数据源。 
    (2)、通过ElementName标记。这个ElementName指定了一个已知的对象名称,将使用它作为绑定数据源。 
    (3)、通过RelativeRource标记。这个标记将在后面说明ControlTemplate和Style时再进行说明。
    2.绑定控件的值
    <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <Slider x:Name="imageSlider" Orientation="Horizontal" Maximum="600" Minimum="100" Value="100" />
     <Image Source="gypsy.jpg" Width="{Binding ElementName=imageSlider, Path=Value}" Height="{Binding ElementName=imageSlider, Path=Value}" />
    </StackPanel>

  • 相关阅读:
    python之socket编程
    python之异常处理
    面向对象进阶
    openstack的网络配置
    VLAN,GRE,VXLAN
    三节点搭建openstack-Mitaka版本
    矩阵转换
    判断区域相交的方法
    Centos 6.5 Multipath 初始配置
    CentOS开机自动运行程序的脚本
  • 原文地址:https://www.cnblogs.com/single/p/1155879.html
Copyright © 2011-2022 走看看