0

我想获取 Datagrid Cell 的事件触发器。我的意思是说我想写这样的东西

**<EventTrigger EventName="MouseEnter">**

然后从 XAML 调用函数 this:

void Cell_MouseEnter(对象发送者,MouseEventArgs e)

我该怎么做:

我在 XAML 中有这个

    <ctrls:RhinoDataGrid x:Name="dataGrid" Grid.Row="1" Margin="5" ItemsSource="{Binding Model.CurrentDataTable}"   
                             Style="{StaticResource RhinoDataGridBaseStyle}" IsReadOnly="{Binding Model.IsLinkFile}"
                             SelectedValue="{Binding Model.CurrentDataRow}" SelectedValuePath="Row"                                 SetAutomappingOnOff="{Binding IsAutoMap, Mode=TwoWay}" >
            </ctrls:RhinoDataGrid>


     <Style TargetType="{x:Type DataGridCell}">
            <Setter Property="BorderBrush" Value="Transparent"></Setter>
            <Setter Property="BorderThickness" Value="2"></Setter>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Foreground" Value="White"></Setter>
                    <Setter Property="BorderBrush" Value="{DynamicResource ActiveItemBrush}"></Setter>
                    <Setter Property="BorderThickness" Value="2"></Setter>
                </Trigger>
            </Style.Triggers>            

请帮忙

谢谢迪

4

3 回答 3

0

EventSetter你很困惑EventTrigger......

  <Style TargetType="{x:Type DataGridCell}"> 
       <EventSetter Event="MouseEnter" Handler="Cell_MouseEnter"/>
  </Style> 
于 2012-05-15T08:45:27.473 回答
0

改为检查“ IsMouseOver ”。我假设“ RhinoDataGrid ”继承自我们已知的 WPF 的 DataGrid。

于 2012-05-14T18:40:11.873 回答
0
<Style TargetType="{x:Type DataGridCell}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridCell}">
              <Grid Mouse.MouseEnter="Cell_MouseEnter" Background="{TemplateBinding Background}">       
                 <ContentPresenter/>
              </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
于 2012-05-14T19:09:26.350 回答