当前位置:   article > 正文

数据绑定之prism_microsoft.practice.prism.dll文件

microsoft.practice.prism.dll文件

红色的字体比较重要了!!!!这个讲完了,接下我讲讲prism了。。。

1.解压Prismv4.exe,找到Source.zip里的bin\Desktop\Microsoft.Practices.Prism.dll;

2.在工程中引用.

3.建立ViewModels文件夹,新增xxxWindowViewModel.cs:

示例内容如下:

using ...
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Commands;

namespace WpfApplication1.ViewModels
{
    class MainWindowViewModel : NotificationObject
    {
        private string loginId;
        public string LoginId
        {
            get { return loginId; }
            set
            {
                loginId = value;
                this.RaisePropertyChanged("LoginId");
            }
        }

       
        public DelegateCommand LoginCommand { get; set; }
        private void LoginCommandExecute()
        {
            MessageBox.Show(LoginId);
        }
        public MainWindowViewModel ()
     {
            this.LoginCommand = new DelegateCommand(new Action(this.LoginCommandExecute));
     }
    }
}

4.xaml文件中进行数据绑定,并在.cs中指定DataContext

this.Datacontext=new MainWindowViewModel();

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/746095
推荐阅读
相关标签
  

闽ICP备14008679号