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的更多相关文章

  1. Devexpress Winform MVVM

    归纳总结备忘 Devexpress Winform MVVM Practice 前言 MVVM Devexpress 正文 databindings及 UI Triggers Command 委托Co ...

  2. DevExpress winform XtraEditor常用控件

    最近在公司里面开始使用DevExpress winform的第三方控件进行开发和维护,这里整理一些常用控件的资料以便于后续查看 ComboBoxEdit 这个控件和winform自带的控件差不多,使用 ...

  3. DevExpress Winform 常用控件

    Ø  前言 DevExpress 控件的功能比较强大,是全球知名控件开发公司,对于开发 B/S 或 C/S 都非常出色,可以实现很炫且功能强大的效果. DevExpress Winform 常用控件是 ...

  4. DevExpress Winform 通用控件打印方法(允许可自定义边距) z

    DevExpress Winform 通用控件打印方法,包括gridcontrol,treelist,pivotGridControl,ChartControl,LayoutControl...(所有 ...

  5. DevExpress Winform使用单例运行程序方法和非DevExpress使用Mutex实现程序单实例运行且运行则激活窗体的方法

    原文:DevExpress Winform使用单例运行程序方法和非DevExpress使用Mutex实现程序单实例运行且运行则激活窗体的方法 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA ...

  6. Devexpress Winform初学笔记

    作为一个软件开发人员来说,得有自己的博客,可以用来ZB,哈哈!玩笑话..... 写博客并不仅仅是用来ZB的,他可以用来记录你在技术道路上探索遇到的坎,当然也有提高逼格的次然因素啦!小弟刚入博客园不久, ...

  7. Devexpress Winform Gridcontrol 中根据条件单元格的值改变单元格的颜色等属性。

    提供一下三种方法 1.使用设计器 点击gridcontrol控件,run designer,format Condtions, add,然后进行各种条件的设置. 2.用代码代替设计器. 实例代码: p ...

  8. 强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择 z

    关键代码请参考http://www.devexpress.com/Support/Center/p/K18333.aspx 最新DEMO 下载 The current GridLookUpEdit's ...

  9. DevExpress winform 友好皮肤

    DevExpress设置默认皮肤及各种皮肤样式   DevExpress设置默认皮肤及各种皮肤样式 设置默认皮肤代码: 在程序入口Program.cs里添加如下代码 引用using DevExpres ...

随机推荐

  1. python服务器文件上传下载+GUI【tkinter】

    大概就是一个通过应用程序来和服务器打交道的这么一个,小东西 1.GUI 用的是tkinter # -*- coding: UTF-8 -*- from tkinter import * import ...

  2. linux/mac下一键删除下载失败的maven jar包

    echo 正在搜索... find . -name "*lastUpdated" | xargs rm -fr echo 搜索完毕

  3. mysql查看正在执行的sql语句

    有2个方法: 1.使用processlist,但是有个弊端,就是只能查看正在执行的sql语句,对应历史记录,查看不到.好处是不用设置,不会保存. -- use information_schema; ...

  4. 在 Docker 中使用 mysql 的一些技巧

    启动到后台:  docker-compose start docker-composer 执行命令: entrypoint: pwd app: build: ./app working_dir: /a ...

  5. js 判断 是否在当前页面 当前页面是否在前端

    1.使用visibilitychange 浏览器标签页被隐藏或显示的时候会触发visibilitychange事件. document.addEventListener("visibilit ...

  6. poj3889 fractal streets

    分形街道 我干,这个毒瘤. 想起来就头痛. 首先看题就是一大难题...... 说一下题目大意吧. 每当n+1时,把n阶图复制为4份.2*2排好. 右边两个不动.左上顺时针旋转90°,左下逆时针旋转90 ...

  7. java参数可变方法

    java中允许一个方法中存在多个参数 public class Parmvarexmple { //参数可变的方法 public int sum(int...n) { int tempSum=0; f ...

  8. Map的嵌套

    package cn.lijun.demo2; import java.util.HashMap; import java.util.Iterator; import java.util.Set; p ...

  9. 基于RBAC模型的权限系统设计(Github开源项目)

    RBAC(基于角色的访问控制):英文名称Rose base Access Controller.本博客介绍这种模型的权限系统设计.取消了用户和权限的直接关联,改为通过用户关联角色.角色关联权限的方法来 ...

  10. django_orm查询性能优化

    查询操作和性能优化 1.基本操作 增 models.Tb1.objects.create(c1='xx', c2='oo') 增加一条数据,可以接受字典类型数据 **kwargs obj = mode ...