2010-06-25 3 views
0

DataGridControl 이벤트 대신 xaml의 각 행에 DoubleClickEvent를 추가 할 수 있습니까? 이 같은xaml의 각 행에 EventToCommand 추가

무엇인가 (이 코드는 작동하지 않습니다) :

<UserControl 
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
     xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras" 
     xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" > 
    <xcdg:UserControl.Resources> 
      <Style TargetType="xcdg:DataRow"> 
       <i:Interaction.Triggers> 
        <i:EventTrigger EventName="MouseDoubleClick"> 
         <cmd:EventToCommand Command="{Binding SelectCommand, Mode=Default}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:DataGridControl}}}" /> 
        </i:EventTrigger> 
       </i:Interaction.Triggers> 
      </Style> 
    </xcdg:UserControl.Resources> 
... 

답변

1

대신 스타일의 템플릿을 사용하십시오. (여기서는 xceed DataGrid의 DataRow가 템플릿 가능하다고 가정합니다.)

<UserControl ...> 
    <UserControl.Resources> 
     <ResourceDictionary> 
      <DataTemplate x:Key="DataTemplateKey"> 
       <Grid> 
        <i:Interaction.Triggers> 
         <i:EventTrigger EventName="MouseDoubleClick"> 
          <cmd:EventToCommand Command="{Binding SelectCommand}" /> 
         </i:EventTrigger> 
        </i:Interaction.Triggers> 
        <!-- put your row template here --> 
       </Grid> 
       <CheckBox Content="{Binding Path=ApplianceActionID, Converter={StaticResource LookupConverter}, ConverterParameter=ApplianceActionLookupValues}" 
          IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" /> 
      </DataTemplate> 

     </ResourceDictionary> 
    </UserControl.Resources> 

    <!-- UI --> 

</UserControl> 
+0

불행히도 ... 또는 어떻게 찾을 수 없었습니다. – CodeWeasel