zoukankan      html  css  js  c++  java
  • WPF中DataGrid双击命令获取选中的ViewModel

    xaml

    <DataGrid  x:Name="myGrd"
              ItemsSource="{Binding SearchItems}"
              SelectedItem="{Binding SelectedItem}"
              SelectionMode="Single"
              SelectionUnit="FullRow">
    
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
                <cmd:EventToCommand Command="{Binding MouseDoubleClickCommand}"  
                                    CommandParameter="{Binding ElementName=myGrd, Path=SelectedItem}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>
        ...
    </DataGrid>

    ViewModel

    public ICommand MouseDoubleClickCommand
    {
        get
        {
            if (mouseDoubleClickCommand == null)
            {
                mouseDoubleClickCommand = new RelayCommand<SearchItem>(
                    item =>
                    {
                        var selectedetitem = item;
                    }
                    );
            }
            return mouseDoubleClickCommand;
        }
    }
  • 相关阅读:
    Matrix-tree 定理的一些整理
    多项式
    多项式
    vijos 1641 Vs Snowy
    noip 提高组 2010
    军训有感
    我的将军啊
    洛谷 P3302 [SDOI2013]森林
    关于线段树
    关于KMP
  • 原文地址:https://www.cnblogs.com/saybookcat/p/5190892.html
Copyright © 2011-2022 走看看