资源简介
WPF对比WinForm简单实例,这个例子主要展示同一个需求用WinForm和WPF分别进行实现,通过这个例子,我们可以看到两者之间的区别和联系,同时也可以对我们的项目选型带来一定的参考作用
代码片段和文件信息
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
namespace Businessobjects
{
public class Company : INotifyPropertyChanged
{
#region 创建数据方法
public static Company[] GetCompanys()
{
// 在真正的应用程序中,这可能会调用数据访问层,从数据库中获取记录。
return new Company[]
{
new Company(1 “博客园“ “CNBlogs“ GetPictureFile(1) new DateTime(2004 1 12))
new Company(2 “51CTO“ “51CTO“ GetPictureFile(2) new DateTime(2005 3 1))
new Company(3 “CSDN“ “CSDN“ GetPictureFile(3) new DateTime(2000 1 20))
new Company(4 “开源中国“ “开源中国“ GetPictureFile(4) new DateTime(2008 8 1))
new Company(5 “ITEYE“ “ItEye“ GetPictureFile(5) new DateTime(2011 4 1))
};
}
private static string GetPictureFile(int CompanyID)
{
string fileName = String.Format(“emp{0}.jpg“ CompanyID);
string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
folder = Path.Combine(folder “Images“);
return Path.Combine(folder fileName);
}
private Company(int id string chineseName string EnglishName string pictureFile DateTime startDate)
{
this.ID = id;
this.chineseName = chineseName;
this.EnglishName = EnglishName;
this.PictureFile = pictureFile;
this.StartDate = startDate;
}
#endregion // 创建数据方法
#region 实体属性
public int ID { get; private set; }
string _chineseName;
public string chineseName//中文名称
{
get { return _chineseName; }
set
{
if (value == _chineseName)
return;
_chineseName = value;
this.onpropertychanged(“chineseName“);
this.onpropertychanged(“FullName“);
}
}
string _EnglishName;
public string EnglishName//英文名称
{
get { return _EnglishName; }
set
{
if (value == _EnglishName)
return;
_EnglishName = value;
this.onpropertychanged(“EnglishName“);
this.onpropertychanged(“FullName“);
}
}
public string FullName
{
get { return String.Format(“{0} {1}“ this.EnglishName this.chineseName); }
}
public string PictureFile { get; private set; }//图片文件地址
public DateTime StartDate { get; private set; }//开始时间
#endregion // 实体属性
#region INotifyPropertyChanged 接口
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void onpropertychanged(string propertyName)//属性变更通知
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
handler(this new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 113152 2018-12-28 08:53 WinFormsAndWPFCompare\WinFormsAndWPFCompare\.vs\WinFormsAndWPFCompare\v15\.suo
文件 0 2018-12-25 11:46 WinFormsAndWPFCompare\WinFormsAndWPFCompare\.vs\WinFormsAndWPFCompare\v15\Server\sqlite3\db.lock
文件 733184 2018-12-28 08:53 WinFormsAndWPFCompare\WinFormsAndWPFCompare\.vs\WinFormsAndWPFCompare\v15\Server\sqlite3\storage.ide
文件 6656 2018-12-27 10:26 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 15872 2018-12-27 10:26 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 5793 2010-07-07 21:50 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 4318 2010-07-07 21:51 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 4500 2010-07-07 21:51 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 3962 2018-12-26 11:12 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 9221 2018-12-26 11:20 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 3321 2018-12-26 11:35 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 228 2018-12-26 11:25 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 3104 2018-12-27 08:55 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 5793 2010-07-07 21:50 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 4318 2010-07-07 21:51 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 4500 2010-07-07 21:51 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 3962 2018-12-26 11:12 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 9221 2018-12-26 11:20 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
..A.SH. 22016 2010-07-07 21:52 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 42 2018-12-26 11:33 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 3197 2018-12-26 11:35 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 7660 2018-12-26 15:14 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 6656 2018-12-27 10:26 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 15872 2018-12-27 10:26 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 674 2018-12-26 15:14 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 7077 2018-12-26 11:31 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 1442 2008-05-03 15:32 WinFormsAndWPFCompare\WinFormsAndWPFCompare\Businessob
文件 2103 2018-12-25 11:46 WinFormsAndWPFCompare\WinFormsAndWPFCompare\WinFormsAndWPFCompare.sln
..A..H. 52224 2010-07-09 02:07 WinFormsAndWPFCompare\WinFormsAndWPFCompare\WinFormsAndWPFCompare.suo
文件 6656 2018-12-27 10:26 WinFormsAndWPFCompare\WinFormsAndWPFCompare\WinFormsApp\bin\Debug\Businessob
............此处省略123个文件信息
相关资源
- c# scoket异步通信代码
- WPF导出Excel
- WPF自定义控件库_可实现QQ音乐播放器
- WPF中绘制3D地表图,效果和matlab类似
- WpfApplication 界面窗口变换效果的保存
- WPF TreeView递归异步绑定
- wpf datagrid数据导出到execl
- 开源项目图片浏览查看wpf编码
- WPF datagrid RowDetailsTemplate实现伸展收缩
- C# WPF DataGrid控件实现三级联动
- .NET、WPF、 C# 自定义控件拖动,拉伸,
- WPFImageButton自定义控件
- C#实现USB设备通信
- 在WPF中使用淡入淡出的特效播放图片
- WPF拖拽控件(可点击)
- WPF自定义毛玻璃窗口(自适应系统)
- 快速设计一个简单的WPF串口上位机
- WPF 中嵌入其它应用程序窗口
- WPF自定义TreeViewItem 样式
- 用WPF自制的漂亮时钟控件
- C#集合性能测试
- WPF资源字典中的控件事件触发
- WPF自定义表格控件
- c# wpf 实现文件上传功能
- WPF Mircosoft.Ink墨迹手写输入(源码)
- Winform与WPF窗体互相调用方法
- WPFVisifire.Charts5.1.7.0 破解版
- WPF中DataGrid导出Excel和Word
- 在WPF中模拟SL的ChildWindow效果
- c# wpf全套教程视频教程
评论
共有 条评论