我想采用Datagrid Cell的事件触发器。我的意思是说我想写这样的东西
**<EventTrigger EventName="MouseEnter">**
然后从XAML调用函数:
void Cell_MouseEnter(object sender,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>
请帮忙
由于 DEE
答案 0 :(得分:0)
请检查“ IsMouseOver ”。我假设“ RhinoDataGrid ”继承自我们已知的WPF的DataGrid。
答案 1 :(得分: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>
答案 2 :(得分:0)
您将EventSetter
与EventTrigger
....
<Style TargetType="{x:Type DataGridCell}">
<EventSetter Event="MouseEnter" Handler="Cell_MouseEnter"/>
</Style>