zoukankan      html  css  js  c++  java
  • WPF Datagrid multiple selecteditems in MVVM

    I can assure you: SelectedItems is indeed bindable as a XAML CommandParameter

    After a lot of digging and googling, I have finally found a simple solution to this common issue.

    To make it work you must follow ALL the following rules:

    1. Following Ed Ball's suggestion', on you XAML command databinding, define CommandParameterproperty BEFORE Command property. This a very time-consuming bug.

      enter image description here

    2. Make sure your ICommand's CanExecute and Execute methods have a parameter of object type. This way you can prevent silenced cast exceptions that occurs whenever databindingCommandParameter type does not match your command method's parameter type.

      private bool OnDeleteSelectedItemsCanExecute(object SelectedItems)
      {

         // Your goes heres

      }

      private bool OnDeleteSelectedItemsExecute(object SelectedItems)
      {

         // Your goes heres

      }

    For example, you can either send a listview/listbox's SelectedItems property to you ICommand methods or the listview/listbox it self. Great, isn't it?

    Hope it prevents someone spending the huge amount of time I did to figure out how to receiveSelectedItems as CanExecute parameter.

  • 相关阅读:
    android activity lifecycle
    android hal 分析
    android hardware.c 源码分析
    linux cpio
    android boot.img unpack pack
    imx6 android4.2 编译
    repo 安装
    repo manifest.xml 分析
    ElasticSearch 5.0.0 安装部署常见错误或问题
    elasticsearch 安装(基于java运行环境)
  • 原文地址:https://www.cnblogs.com/xpvincent/p/4180804.html
Copyright © 2011-2022 走看看