我想採用Datagrid Cell的事件觸發器。我的意思是說我想寫這樣的事情WPF DatagridCell事件觸發器
**<EventTrigger EventName="MouseEnter">**
,然後從XAML調用此函數:
無效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>
請幫助
感謝 迪
IsMouseOver - 僅適用於風格XAML 我不得不調用代碼隱藏事件,這樣我就可以得到Cell對象 –
無效Cell_MouseEnter(對象發件人,MouseEventArgs e) { }它應該調用此 –