.NET: WPF DependencyProperty
DependencyProperty and DependencyObject is the core of WPF data binding.
We can use this two class to binding one class instead of using INotifyPropertyChanged
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows;
using System.Windows.Data;
namespace WpfApplication1
{
class Student : DependencyObject
{
public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(Student));
public string Name
{
get { return (string)GetValue(NameProperty); }
set { SetValue(NameProperty, value); }
}
//public BindingExpressionBase SetBinding(DependencyProperty dp, BindingBase binding)
//{
// return BindingOperations.SetBinding(this, dp, binding);
//}
}
}
while the other part can be the same as the code in ".NET WPF DataBinding".
In ease, we can key "propdp" and Tab key to edit every parameter in the function instead of key all the characters for the function.
Besides, there is one concept called Attached Properties that can attach new properties to existing class. This part can be referenced to the book
.NET: WPF DependencyProperty的更多相关文章
- wpf “{DependencyProperty.UnsetValue}”不是属性“Background”的有效值。异常
, 在wpf模板中, 有一个Background绑定的值不存在导致的异常, 我的是有这个没有导致的错误, 自己添加之后就没有了
- WPF中监视DependencyProperty的变化
WPF中监视DependencyProperty的变化 周银辉 尽管一个类会提供很多事件,但有时候还是显得不够,比如说前两天我就以为WPF的ListBox控件会有ItemsSourceChange ...
- WPF依赖属性DependencyProperty
写在之前: 依赖属性算是WPF醉醉基础的一个组成了.平时写代码的时候,简单的绑定很轻松,但是遇到复杂的层次比较多的绑定,真的是要命.所以,我觉得深刻认识依赖属性是很有必要的.本篇只是个人学习的记录,学 ...
- WPF中的DependencyProperty存储方式详解
前言 接触WPF有一段时间了,之前虽然也经常使用,但是对于DependencyProperty一直处于一知半解的状态.今天花了整整一下午将这个概念梳理了一下,自觉对这个概念有了较为清晰的认识,之前很多 ...
- WPF 依赖属性源码 洞察微软如何实现DependencyProperty
依赖属性DependencyProperty是wpf最重要的一个类,理解该类如何实现对学习wpf帮助很大! 终于找到了该类的源码!仔细阅读源码,看看微软如何玩的花招! File: Base\Syste ...
- WPF基础学习笔记整理 (五) DependencyObject & DependencyProperty
参考资料: 1.http://www.cnblogs.com/Zhouyongh/archive/2009/10/20/1586278.html 基础知识: DependencyObject & ...
- WPF中DependencyObject与DependencyProperty的源代码简单剖析
Windbg调试WPF的依赖属性中提到了wpf的DependencyObject中DependencyProperty是怎样调试查看的. 从中我们看出DO(DependencyObject)与 DP( ...
- WPF 使用依赖属性(DependencyProperty) 定义用户控件中的Image Source属性
原文:WPF 使用依赖属性(DependencyProperty) 定义用户控件中的Image Source属性 如果你要自定义一个图片按钮控件,那么如何在主窗体绑定这个控件上图片的Source呢? ...
- 如何在wpf程序中使用DependencyProperty
作为例子,我决定定义一个MyBorderEx,在WPF常用的"Border"控件中创建一个名为Transparency的属性,来指示它的透明度,这个属性值在0-255间变化,255 ...
随机推荐
- 低功耗蓝牙BLE [学习笔记]
手机设备会区分 "connecting" and "pairing" ,前者可以自动连接,后者则需要请求.BLE不再有pairing的麻烦,能直接连上目标设备, ...
- useful tools, excel import mysql,swagger
http://www.th7.cn/Program/java/201602/765943.shtml------swagger http://blog.csdn.net/csfreebird/arti ...
- mysql import data slow solution---overview information
1 SELECT SUM(DATA_LENGTH)+SUM(INDEX_LENGTH) FROM information_schema.tables WHERE TABLE_SCHEMA='dat ...
- 从高版本JDK换成低版本JDK报错Unsupported major.minor version 52.0
ava.lang.UnsupportedClassVersionError: PR/Sort : Unsupported major.minor version 52.0这个错误是由于高版本的java ...
- ArcGIS Engine开发之旅02--ArcGIS Engine中的类库
原文:ArcGIS Engine开发之旅02--ArcGIS Engine中的类库 System类库 System类库是ArcGIS体系结构中最底层的类库.System类库包含给构成ArcGIS的其他 ...
- partial类与[MetadataType(typeof(类名))]有什么区别?
在MVC的Model中,我们可以定义很多与视图相关的元数据,这些元数据对我们开发视图起着相当重要的作用,特别是在数据验证方面.这些元数据一般情况下我们是不会定义在业务实体(或持久化实体)上面,所以很多 ...
- [RVM is not a function] Interating RVM with gnome-terminal
Ubuntu 12.04 64bit LTS, running the 'rvm use 1.9.3' brings the 'RVM is not a function' warning. Here ...
- Hibernate报错解决Error parsing JNDI name [],Need to specify class name
能实现写数据,但是报错. 出错信息: 十月 21, 2016 3:46:18 下午 org.hibernate.Version logVersionINFO: HHH000412: Hibernate ...
- Eclipse常用设置(转)
http://jingyan.baidu.com/article/3065b3b6efa9d7becff8a4c6.html 用惯了VS,再回过去用Eclipse真是一件痛苦的事.so,在这里记录下使 ...
- Android 退出app,后台推送的服务也停止了,怎么可以做到不停止后台服务呢?
service粘性等的那4种方式试了,三星的可以,小米老款手机可以,新款不行,华为新款也不行,还有魅族什么的,都不行,新款的手机上都有一个安全中心,只有在安全中心里面添加上允许app自启动才可以 怎么 ...