【.Net码农】WPF组件开发之组件的基类
来源:互联网 发布:网络晒长腿大赛 编辑:程序博客网 时间:2024/05/17 07:12
WPF组件开发之组件的基类
http://www.cnblogs.com/BeiJing-Net-DaiDai/p/3248034.html
之前在网上看到很多关于组件开发的资料,但真正可以用到框架内的却很少。今天贴出自己做的组件,并适合大部分框架的代码。
组件开发需要先做出组件的基类,然后由其他的各类组件去继承这个基类,下面是组件基类的代码。
组件基类:
public abstract class Component { public abstract string Name { get; } public abstract string Icon { get; } public abstract string Description { get; } public abstract ComponentEvent ComponentEvent { get; } public abstract ComponentProperty ComponentProperty { get; } public abstract UIElement CreateUIElement(); }
组件基类的属性:
public abstract class ComponentProperty : INotifyPropertyChanged { private double width; private double height; private double left; private double top;private string name; [Category("基本")] [Description("名称")] public string Name { get { return name; } set { if (name == value) return; name = value; OnPropertyChanged("Name"); } } [Category("大小")] [Description("宽度")] public double Width { get { return width; } set { if (width == value) return; width = value; OnPropertyChanged("Width"); } } [Category("大小")] [Description("高度")] public double Height { get { return height; } set { if (height == value) return; height = value; OnPropertyChanged("Height"); } } [Category("位置")] [Description("距左")] public double Left { get { return left; } set { if (left == value) return; left = value; OnPropertyChanged("Left"); } } [Category("位置")] [Description("距上")] public double Top { get { return top; } set { if (top == value) return; top = value; OnPropertyChanged("Top"); } } #region INotifyPropertyChanged Members //属性的监听事件 public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName"); PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } #endregion }
组件基类的事件:
public abstract class ComponentEvent : INotifyPropertyChanged{#region 这个可以去掉private string _Click;public string Click{ get{return _Click;} set{ if(_Click==value)return; _Click=value; OnPropertyChanged("Click"); }}public void OnClick(object sender,RoutedEventArgs e){ if(Click!=null){ //事件的处理 }}#endregion#region INotifyPropertyChanged Members//监听事件public event PropertyChangedEventHandler PropertyChanged;protected void OnPropertyChanged(string propertyName){if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");PropertyChangedEventHandler handler = PropertyChanged;if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));}#endregion}
以上是组件的基类,组件基类打包为模板以及组件开发请关注后续章节,加群可优先哦。
WPF、AE技术交流群:94234450 点击加入QQ群:
分类: 组件开发
绿色通道: 好文要顶关注我 收藏该文与我联系
0 0
- 【.Net码农】WPF组件开发之组件的基类
- 【.Net码农】WPF组件开发
- WPF自定义组件开发实践
- .NET组件开发
- .net 组件开发资源
- Asp.Net开发组件
- .net开发实用组件
- .net组件开发
- 基于组件的.NET软件开发(1)
- 基于组件的.NET软件开发(3)
- 开发 .NET 下的 FTP 客户端组件
- 开发 .NET 下的 FTP 客户端组件
- 基于组件的.NET软件开发(1)
- 基于组件的.NET软件开发(3)
- 关于VB.net的组件开发(一)
- .NET平台常用的开发组件
- WPF组件化开发技术实践
- WPF开发一款软件自动升级组件
- malloc、calloc、realloc,alloca 的区别
- ctags和vim的安装和使用详解
- log4j设置
- Hadoop 2.6.0 Configuration源码分析
- 从驱动层将USB3.0转换为USB2.0
- 【.Net码农】WPF组件开发之组件的基类
- selenium IDE下载
- C语言实现的一个简单的HTTP程序
- 博客文章优化的一些小技巧
- js 文件压缩
- Java线程池
- Flash and Scalform CLIK
- Android4.4 SystemUI分析之Clock时钟显示
- 再看数据库——(7)游标