WPF中的属性绑定 binding
来源:互联网 发布:c语言写纸牌类游戏 编辑:程序博客网 时间:2024/04/26 23:13
今天试着用data binding写了个小程序, 发现对c#的基本概念还是不清楚,导致走了弯路
window 1.xaml
<Window x:Class="bindtest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300"
xmlns:localadd ="clr-namespace:bindtest"
>
<DockPanel>
<DockPanel.Resources>
<localadd:MyData x:Key="vaav" />
</DockPanel.Resources>
<DockPanel.DataContext>
<Binding Source="{StaticResource vaav}"/>
</DockPanel.DataContext>
<Button Click="ClickMe" Background="{Binding Path=colorName }" Width="150" Height="30">
I am bound to be RED!
</Button>
</DockPanel>
</Window>
MyData.cs
using System;
namespace bindtest
{
public class MyData
{
private string ColorName = "Red";
public string colorName
{
get { return ColorName; }
set { ColorName = value; }
}
}
}
文档中说Path=colorName , colorName是属性字段, 就是对属性这个基本概念的不清,导致我写成了
using System;
namespace bindtest
{
public class MyData
{
public string colorName = "Red"; //Error code
}
}
- WPF中的属性绑定 binding
- wpf中的 绑定Binding MultiBinding StringFormat格式转化问题
- WPF绑定(Binding)讲解大全
- wpf 后台绑定数据 binding
- WPF绑定Binding及模式
- c#--wpf数据绑定binding
- WPF中的Binding
- WPF中的Binding(一)
- WPF中的Binding
- WPF中的binding
- WPF中的binding(十二)- 多路Binding
- WPF 值绑定binding (上)
- JSF中的binding属性
- WPF实例秀不用属性也Binding
- WPF中的绑定杂记
- WPF 中的数据绑定
- WPF 绑定中的TargetNullValue
- WPF中的binding(九)- 使用Binding的RelativeSource
- 标准
- 装了vista 一小时后换回xp!
- JSP内置对象
- 測試
- Servlets/JSP开发技术问答
- WPF中的属性绑定 binding
- asp和jsp的内建对象简要说明
- Avoiding Multiple Instances of an Application
- 重返博客第二天
- 养乌龟
- 关于下拉菜单与查询的问题
- jsp内建对象详解
- 不用电脑可以读写U盘上的文件吗?
- JAVA中的汉字编码问题