Devexpress Winform 使用MVVM
MVVM在WPF里很早就有了,在Winform里Devexpress最近几个大版本才有的事,上一段代码。
现在对话框上添加三个控件simpleButton1,simpleButton2,textEdit1,MvvmContext组件
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
//
// POCO View Model provides out-of-the-box support of the INotifyPropertyChanged.
//
public class ViewModel
{
// Bindable property will be created from this property.
public virtual string Title { get; set; }
// Just a method for readability
public string GetTitleAsHumanReadableString()
{
if (Title == null)
return "(Null)";
if (Title.Length == 0)
return "(Empty)";
if (string.IsNullOrWhiteSpace(Title))
return "(WhiteSpace)";
return Title;
}
}
public Form1()
{
InitializeComponent();
} private void simpleButton1_Click(object sender, EventArgs e)
{ // Set type of POCO-ViewModel
mvvmContext1.ViewModelType = typeof(ViewModel);
// Data binding for the Title property (via MVVMContext API)
mvvmContext1.SetBinding(textEdit1, c=>c.EditValue, "Title");
// UI binding for the Report command
ViewModel viewModel = mvvmContext1.GetViewModel<ViewModel>();
simpleButton2.Click += (s, ee) => XtraMessageBox.Show(viewModel.GetTitleAsHumanReadableString()); }
当simpleButton1点击执行后,simpleButton2点击后显示的就是textEdit1的值。
Devexpress Winform 使用MVVM的更多相关文章
- Devexpress Winform MVVM
归纳总结备忘 Devexpress Winform MVVM Practice 前言 MVVM Devexpress 正文 databindings及 UI Triggers Command 委托Co ...
- DevExpress winform XtraEditor常用控件
最近在公司里面开始使用DevExpress winform的第三方控件进行开发和维护,这里整理一些常用控件的资料以便于后续查看 ComboBoxEdit 这个控件和winform自带的控件差不多,使用 ...
- DevExpress Winform 常用控件
Ø 前言 DevExpress 控件的功能比较强大,是全球知名控件开发公司,对于开发 B/S 或 C/S 都非常出色,可以实现很炫且功能强大的效果. DevExpress Winform 常用控件是 ...
- DevExpress Winform 通用控件打印方法(允许可自定义边距) z
DevExpress Winform 通用控件打印方法,包括gridcontrol,treelist,pivotGridControl,ChartControl,LayoutControl...(所有 ...
- DevExpress Winform使用单例运行程序方法和非DevExpress使用Mutex实现程序单实例运行且运行则激活窗体的方法
原文:DevExpress Winform使用单例运行程序方法和非DevExpress使用Mutex实现程序单实例运行且运行则激活窗体的方法 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA ...
- Devexpress Winform初学笔记
作为一个软件开发人员来说,得有自己的博客,可以用来ZB,哈哈!玩笑话..... 写博客并不仅仅是用来ZB的,他可以用来记录你在技术道路上探索遇到的坎,当然也有提高逼格的次然因素啦!小弟刚入博客园不久, ...
- Devexpress Winform Gridcontrol 中根据条件单元格的值改变单元格的颜色等属性。
提供一下三种方法 1.使用设计器 点击gridcontrol控件,run designer,format Condtions, add,然后进行各种条件的设置. 2.用代码代替设计器. 实例代码: p ...
- 强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择 z
关键代码请参考http://www.devexpress.com/Support/Center/p/K18333.aspx 最新DEMO 下载 The current GridLookUpEdit's ...
- DevExpress winform 友好皮肤
DevExpress设置默认皮肤及各种皮肤样式 DevExpress设置默认皮肤及各种皮肤样式 设置默认皮肤代码: 在程序入口Program.cs里添加如下代码 引用using DevExpres ...
随机推荐
- HDU--5519 Sequence II (主席树)
题目链接 2016年长春ccpc I 题 题目大意 : 给你n(n≤2∗105n≤2∗105)个数,每个数的大小 0<Ai≤2∗10^5 0<Ai≤2∗10^5. 再给你m(m≤2∗1 ...
- numpy 多维数组及数组操作
NumPy是Python语言的一个扩充程序库.支持高级大量的维度数组与矩阵运算,此外也针对数组运算提供大量的数学函数库.Numpy内部解除了Python的PIL(全局解释器锁),运算效率极好,是大量机 ...
- 代码合并工具Beyond Compare的使用技巧
使用技巧 文件合并 过滤 https://edi.wang/post/2013/2/17/using-beyond-compare 文件夹比较 http://www.beyondcompare.cc/ ...
- apply-javascript-internal
代码如下:喜欢这种封装方式 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charse ...
- ubuntu vim01
不小心按了ctrl+s(停止向终端输入),解决办法ctrl+q(恢复向终端输入)
- 【译】6. Java反射——Getter和Setter
原文地址:http://tutorials.jenkov.com/java-reflection/getters-setters.html ============================== ...
- shell之case
在shell变成中,case语句是if语句的一种扩展,将if中的判断语句,展开,同一个变量,对应多个可能的值时,执行不同的操作.具体句型如下: case "变量" in value ...
- RabbitMQ 消费者的消息确认机制
消息确认的几点说明: 1. Basic.Ack 发回给 RabbitMQ 以告知,可以将相应 message 从 RabbitMQ 的消息缓存中移除.2. Basic.Ack 未被 consumer ...
- svn命令使用;
1.将文件checkout到本地目录 svn checkout svn::xxxxxxxx 简写: svn co 2.往版本库中添加新的文件 svn add files 例如:svn add test ...
- qml性能优化(来源于群友分享);
Qt quick性能优化 使用时间驱动 避免定时轮询: 使用信号槽形式: 使用多线程 C++; QML WorkerScript元件: 使用Qt Quick Compiler 只需要再PRO文件中添加 ...