zoukankan      html  css  js  c++  java
  • WPF MultiSelect MVVM

     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
            xmlns:ii="http://schemas.microsoft.com/expression/2010/interactivity"
    
      <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding SelectedItemsCmd}" CommandParameter="{Binding Path=SelectedItems,ElementName=dg}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
    private ICommand selectedItemsCmd;
            public ICommand SelectedItemsCmd
            {
                get
                {
                    if(selectedItemsCmd==null)
                    {
                        selectedItemsCmd = new DelegateCommand(SelectedItemsCmdExecuted);
                    }
                    return selectedItemsCmd;
                }
            }
    
            private void SelectedItemsCmdExecuted(object obj)
            {
                System.Collections.IList items = (System.Collections.IList)obj;
                if(items!=null && items.Count>0)
                {
                    var collection = items.Cast<SalesOrderDetail>();
                    SelectedOrders = new ObservableCollection<SalesOrderDetail>(collection);
                }                        
            }
  • 相关阅读:
    python GUI
    Python 博客网站资源
    Python 100 天学习计划
    pycharm基本设置
    MySQL 57安装部署(Zip版)(Windows版)
    nginx在centos下的安装
    仓位计算
    python笔记
    vue(一)--监听事件
    Hibernate(五)--级联
  • 原文地址:https://www.cnblogs.com/Fred1987/p/14074985.html
Copyright © 2011-2022 走看看