zoukankan      html  css  js  c++  java
  • WPF MVVM,Prism,Command Binding

    1.添加引用Microsoft.Practices.Prism.Mvvm.dll,Microsoft.Practices.Prism.SharedInterfaces.dll;

    2.新建文件夹,View,ViewModel,View中添加新项FirstView.XAML(Window页面),在ViewModel中添加新项FirstViewModel.CS(类);

    3.在FirstView.xaml.cs的构造函数中添加  DataContext=new FirstViewModel();

    4.在FirstView页面,添加<Button Width="300" Height="100" FontSize="50" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="10" Command="{Binding BtnCommand}" Content="Click Here"/> 绑定命令;

    5.在FirstViewModel.CS页面中添加

    private ICommand _BtnCommand;

    public ICommand BtnCommand
    {
    get
    {
    if (_BtnCommand == null)
    {
    _BtnCommand=new DelegateCommand<string>((obj)=>Add(10,20));
    }
    return _BtnCommand;
    }
    }

    public void Add(int x, int y)
    {
    int z = x + y;
    MessageBox.Show(z.ToString());
    }

  • 相关阅读:
    jsp.图书馆
    jsp第七次作业
    jsp第六次作业
    jsp第四次作业
    JSP第二次作业
    软件测试课堂练习
    Android第六次作业
    Android第五次作业
    Android第四次作业
    Android第三次作业
  • 原文地址:https://www.cnblogs.com/Fred1987/p/5547618.html
Copyright © 2011-2022 走看看