首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏林德熙的博客

    WPF DelegateCommand 出现Specified cast is not valid

    使用 DelegateCommand 出现 Specified cast is not valid 最近写快捷键需要 DelegateCommand ,于是用了 DelegateCommand<double > ,运行时出现 Specified cast is not valid 原因是 DelegateCommand 传入的 Object 是可空的,如果使用 Double ,那么是不可空的,就出现错误 于是就可以啦 如果遇到 DelegateCommand 出现这个错误,一般就是使用不可空的类型,只要让他可空就好。

    43410编辑于 2022-08-04
  • 来自专栏JusterZhu

    05Prism WPF 入门实战 - Navigation

    _loadModulesCommand; private DelegateCommand _openViewA; private DelegateCommand _openViewB ; private DelegateCommand _goBackView; private DelegateCommand _goForwardView; (_openViewA = new DelegateCommand(OpenViewAAction)); } public DelegateCommand OpenViewB (_openViewB = new DelegateCommand(OpenViewBAction)); } public DelegateCommand GoBackView (_goBackView = new DelegateCommand(GoBackViewAction)); } public DelegateCommand GoForwardView

    85320编辑于 2022-12-07
  • 来自专栏WPF

    .NET Core 3 WPF MVVM框架 Prism系列之区域管理器

    (_loadingCommand = new DelegateCommand(ExecuteLoadingCommand)); private DelegateCommand _activePaientListCommand (_activePaientListCommand = new DelegateCommand(ExecuteActivePaientListCommand)); private DelegateCommand (_deactivePaientListCommand = new DelegateCommand(ExecuteDeactivePaientListCommand)); private DelegateCommand (() => IsCanExcute)); private DelegateCommand _deactiveMedicineListCommand; public DelegateCommand (() => IsCanExcute)); private DelegateCommand _loadMedicineModuleCommand; public DelegateCommand

    1.8K30发布于 2020-04-29
  • 来自专栏JusterZhu

    07Prism WPF 入门实战 - Dialog

    GetMessageCommand { get => _getMessageCommand = new DelegateCommand(() => CancelMessageCommand { get => _cancelMessageCommand = new DelegateCommand(() = _loadModulesCommand; private DelegateCommand _showDialogCommand; public IView { get => _loadModulesCommand = new DelegateCommand(InitModules); } public IModuleInfo ModuleInfo ShowDialogCommand { get => _showDialogCommand = new DelegateCommand(ShowDialogAction); } //

    1.8K10编辑于 2022-12-07
  • 来自专栏WPF

    .NET Core 3 WPF MVVM框架 Prism系列之命令

    本文将介绍如何在.NET Core3环境下使用MVVM框架Prism的命令的用法 一.创建DelegateCommand命令      我们在上一篇.NET Core 3 WPF MVVM框架 Prism 二.创建DelegateCommand带参命令 在创建带参的命令之前,我们可以来看看DelegateCommand的继承链和暴露出来的公共方法,详细的实现可以去看下源码 ? 那么,其实已经很明显了,我们之前创建DelegateCommand不是泛型版本,当创建一个泛型版本的DelegateCommand<T>,那么T就是我们要传入的命令参数的类型,那么,我们现在可以把触发命令的 _asyncCommand; public DelegateCommand AsyncCommand => _asyncCommand ?? ; } ); } 也可以更简洁的写法: private DelegateCommand _asyncCommand; public DelegateCommand AsyncCommand

    2.4K61发布于 2020-04-29
  • 来自专栏WPF

    .NET Core 3 WPF MVVM框架 Prism系列之导航系统

    _loginLoadingCommand; public DelegateCommand LoginLoadingCommand => _loginLoadingCommand (_createAccountCommand = new DelegateCommand(ExecuteCreateAccountCommand)); //导航到CreateAccount (_loginMainContentCommand = new DelegateCommand(ExecuteLoginMainContentCommand)); private DelegateCommand private DelegateCommand _goForwardCommand; public DelegateCommand GoForwardCommand => _goForwardCommand _goBackCommand; public DelegateCommand GoBackCommand => _goBackCommand ??

    2.8K30发布于 2020-04-28
  • 来自专栏张善友的专栏

    WPF/Silverlight中的Command

    的内置Command还有需要许多不足,因此在模式与实践团队的Prism项目中也打造一套自己的Command,特别是与UI元素耦合以及不支持命令组合,所以他们在Prism中便增加了另外一套Command:DelegateCommand DelegateCommand:实现了WPF/Silverlight的ICommand接口,仍只支持一个CanExecute和Execute挂接,但其实现一个称为IActiveAware的接口用于指示是否处于集合状态 ,非激活状态的DelegateCommand始终得不到执行。       CompositeCommand:也是WPF/Silverlight的ICommand接口的一个实现,但其同时也是DelegateCommand的组合,可以向其中注册或取消注册DelegateCommand ,当其中所有处于激活状态的内置DelegateCommand都可以被执行时其CanExecute才返回true。

    1.2K50发布于 2018-01-31
  • 来自专栏WPF

    .NET Core 3 WPF MVVM框架 Prism系列之事件聚合器

    <Patient> _mouseDoubleClickCommand; public DelegateCommand<Patient> MouseDoubleClickCommand => (_mouseDoubleClickCommand = new DelegateCommand<Patient>(ExecuteMouseDoubleClickCommand)); IEventAggregator <Medicine> _addMedicineCommand; public DelegateCommand<Medicine> AddMedicineCommand => _addMedicineCommand (_addMedicineCommand = new DelegateCommand<Medicine>(ExecuteAddMedicineCommand)); public SearchMedicineViewModel _cancleSubscribeCommand; public DelegateCommand CancleSubscribeCommand => _cancleSubscribeCommand

    1.8K30发布于 2020-04-29
  • 来自专栏dino.c的专栏

    [Windows] Prism 8.0 入门(上):Prism.Core

    Commanding ICommand 同样是 MVVM 模式的核心元素,DelegateCommand 实现了 ICommand 接口,它最基本的使用形式如下,其中 DelegateCommand 构造函数中的第二个参数 canExecuteMethod 是可选的: public DelegateCommand SubmitCommand { get; private set; } public CanExecute 返回 DelegateCommand 构造函数中的第二个参数 canExecuteMethod 的返回值。如果不传入这个参数,则 CanExecute 一直返回 True。 除了主动调用 RaiseCanExecuteChanged,DelegateCommand 还可以用 ObservesProperty 和 ObservesCanExecute 两种形式监视属性,定于属性的 例如,安装此工具后可以通过 cmd 代码段快速生成一个完整的 DelegateCommand 代码: private DelegateCommand _fieldName; public DelegateCommand

    2.8K60发布于 2020-12-08
  • 来自专栏CSharp编程大全

    WPF MVVM实例一

    WpfApp11.Model; namespace mvvm实例1.ViewModel { public class StudentViewModel { public DelegateCommand public StudentViewModel() { Student = new StudentModel(); ShowCommand = new DelegateCommand Student.StudentEmail = "438679770@qq.com"; Student.StudentSex = "男"; } } public class DelegateCommand CanExecuteChanged(this, EventArgs.Empty); } } } } 代码中,除了定义StudentViewModel类外,还定义了DelegateCommand 我们可以将实现了ICommand接口的命令DelegateCommand赋值给Button(命令源)的Command属性(只有实现了ICommandSource接口的元素才拥有该属性),这样Button

    1.2K30发布于 2021-02-01
  • 来自专栏WPF

    .NET Core 3 WPF MVVM框架 Prism系列之数据绑定

    get { return _text; } set { SetProperty(ref _text, value); } } private DelegateCommand _clickCommnd; public DelegateCommand ClickCommnd => _clickCommnd ?? (_clickCommnd = new DelegateCommand(ExecuteClickCommnd)); void ExecuteClickCommnd() _clickCommnd; public DelegateCommand ClickCommnd => _clickCommnd ?? (_clickCommnd = new DelegateCommand(ExecuteClickCommnd)); void ExecuteClickCommnd()

    1.9K40发布于 2020-04-29
  • 来自专栏JusterZhu

    08Prism WPF 入门实战 - Cmd&EeventAggregator

    private DelegateCommand _printMsg1Command; public DelegateCommand PrintMsg1Command { get => _printMsg1Command (_printMsg1Command = new DelegateCommand(PrintMsgAction)); } 实现command需要执行的内容。 private DelegateCommand _printMsg1Command; private DelegateCommand _printMsg2Command; public DelegateCommand (_printMsg1Command = new DelegateCommand(PrintMsgAction1)); } public DelegateCommand PrintMsg2Command (_printMsg2Command = new DelegateCommand(PrintMsgAction2)); } private void PrintMsgAction1() {

    55010编辑于 2022-12-07
  • 来自专栏CSharp编程大全

    WPF MVVM实例三

    DelegateCommand.cs using System; using System.Collections.Generic; using System.Linq; using System.Text value; this.RaisePropertyChange("Result"); } } public DelegateCommand this.Input2; } public MainWindowViewModel() { this.AddCommand = new DelegateCommand value; this.RaisePropertyChange("Result"); } } public DelegateCommand this.Input2; } public MainWindowViewModel() { this.AddCommand = new DelegateCommand

    1.4K20发布于 2021-02-26
  • 来自专栏dino.c的专栏

    [UWP 自定义控件]了解模板化控件(7):支持Command

    > </StackPanel> public MenuItemSamplePage() { this.InitializeComponent(); var command = new DelegateCommand string text = parameter as string; return string.IsNullOrWhiteSpace(text) == false; } 这里用到的DelegateCommand 也是UWPCommunityToolkit中的类 :DelegateCommand

    72430发布于 2019-01-18
  • 来自专栏林德熙的博客

    WPF 列表右键菜单比较符合 MVVM 的命令绑定方法

    而我的业务是要右击打开下载项的文件夹或文件,此时的数据可以通过对应行的数据拿到 在 ContextMenu 的菜单里面需要绑定命令,而默认的命令不够好用,咱先磨一下刀,新建一个类,请看代码 public class DelegateCommand CanExecuteChanged; } 通过这个类就可以在 XAML 写绑定命令的资源和代码,请看代码 <local:DelegateCommand x:Key="OpenFileCommand " ExecuteDelegate="OpenFileCommand_OnExecute" ></local:DelegateCommand> <local:DelegateCommand x:Key ="OpenFolderCommand" ExecuteDelegate="OpenFolderCommand_OnExecute" ></local:DelegateCommand> 记得在 cs 代码里面添加对应的

    4.2K20发布于 2020-07-28
  • 来自专栏dotNET编程大全

    C# 一个基于.NET Core3.1的开源项目帮你彻底搞懂WPF框架Prism

    Change Convention 更改ViewModelLocator命名约定 ViewModelLocator - Custom Registrations 为特定视图手动注册ViewModels DelegateCommand 使用DelegateCommandDelegateCommand<T> CompositeCommands 了解如何使用CompositeCommands作为单个命令调用多个命令 IActiveAware return _message; } set { SetProperty(ref _message, value); } } public DelegateCommand MessageViewModel(IEventAggregator ea) { _ea = ea; SendMessageCommand = new DelegateCommand

    2.6K20编辑于 2022-04-19
  • 来自专栏林德熙的博客

    WPF 托盘显示 NotifyIcon WPF

    双击托盘运行代码需要添加命令,创建一个 ViewModel 用来绑定命令 public class DelegateCommand : ICommand { public public ICommand ShowWindowCommand { get { return new DelegateCommand public ICommand HideWindowCommand { get { return new DelegateCommand ICommand ExitApplicationCommand { get { return new DelegateCommand

    8.4K31发布于 2019-03-13
  • 来自专栏CSharp编程大全

    WPF【框架学习】MVVM初探(经典)

    Microsoft YaHei;font-size:14px;">class MainWindowViewModel : NotificationObject { //通过委托形式,定义命令属性 public DelegateCommand PlaceOrderCommand { get; set; } public DelegateCommand SelectMenuItemCommand { get; set; } private this.LoadRestaurant(); this.LoadDishMenu(); //单向“命令属性”的加载过程,通过实例化委托的形式 this.PlaceOrderCommand = new DelegateCommand (new Action(this.PlaceOrderCommandExecute)); this.SelectMenuItemCommand = new DelegateCommand(new Action ) { this.Count = this.DishMenu.Count(i => i.IsSelected == true); } } 这个"栗子"当中,发现“public DelegateCommand

    3.4K20发布于 2021-02-26
  • 来自专栏水击三千

    Silverlight学习(二)

    this.AllColors = new[] { "Red", "Blue", "Green" }; 12 13 this.SubmitCommand = new DelegateCommand <object>(this.OnSubmit);//实例化一个command,DelegateCommand引用类库 Microsoft.Practices.Prism.Commands 14 其中Button控件绑定了无参数的ICommand命令,后台为DelegateCommand。通过Button控件 我们可以获取到数据源的变化,并将它显示到页面上。。

    1.1K100发布于 2018-02-27
  • 来自专栏DotNet程序园

    .NET Core 3 WPF MVVM框架 Prism系列之模块化

    MainWindowViewModel(IModuleManager moduleManager) { _moduleManager = moduleManager; } private DelegateCommand _loadPatientModuleCommand; public DelegateCommand LoadPatientModuleCommand => _loadPatientModuleCommand (_loadPatientModuleCommand = new DelegateCommand(ExecuteLoadPatientModuleCommand)); void ExecuteLoadPatientModuleCommand

    2.1K20发布于 2020-02-18
领券