zoukankan      html  css  js  c++  java
  • 【Silverlight】以MVVM友好的方式使用DataGrid的SelectedItems属性

     今天遇到了这样一个问题,通过多选DataGrid中的列,然后批量删除或更新。但是,Silverlight里DataGrid控件的SelectedItems属性无法以MVVM的方式绑定,因为它是个只读属性。

    后来想到无非是传递到ViewModel中,用CommandParameter传递不就好了。

    XAML:

    <Button Content="删除"Margin="4" Command="{Binding DeleteCommand}"
                            CommandParameter="{Binding SelectedItems,ElementName=MyGrid}"/>

     C#:

    public IActionCommand<object> DeleteCommand { get; set; }
    DeleteCommand = new ActionCommand<object>(Delete);
    
    void Delete(object rows)
    {
          var entities = rows as System.Collections.IEnumerable;
           //todo ...
    }

    我使用的MVVM框架是Jounce

  • 相关阅读:
    python day09
    python day08
    python day07
    python day06
    python day05
    Django-Form组件之字段
    python装饰器
    npm常用命令
    python常用模块-re 正则表达式
    Django-forms效验组件
  • 原文地址:https://www.cnblogs.com/slmk/p/2837587.html
Copyright © 2011-2022 走看看