1

我有WPF DataGrid一个event handler CellEditEnding,我想要一个简单code的改变编辑cell里面的背景颜色event handler

4

1 回答 1

1

下面的代码在成功编辑后使单元格变为粗体。

风格

  <Style TargetType="Controls:DataGridCell" 
   BasedOn="{StaticResource {x:Type Controls:DataGridCell}}" 
   x:Key="CellBoldStyle">
<Style.Triggers>
    <EventTrigger RoutedEvent="Binding.SourceUpdated">
    <BeginStoryboard>
        <Storyboard>
        <ObjectAnimationUsingKeyFrames
            Duration="00:00:00.5"                                   Storyboard.TargetProperty
                                    ="(TextBlock.FontWeight)">
            <DiscreteObjectKeyFrame KeyTime="00:00:00" 
                                Value="{x:Static FontWeights.Normal}" />
            <DiscreteObjectKeyFrame KeyTime="00:00:00.5" 
                                Value="{x:Static FontWeights.Bold}" />
        </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
</Style.Triggers>
  </Style>

柱子

  <Controls:DataGridTextColumn 
             Binding="{Binding Side, Mode=TwoWay, 
                               NotifyOnTargetUpdated=True, 
                               NotifyOnSourceUpdated=True}" 
             CellStyle="{StaticResource CellBoldStyle}" />
于 2012-10-26T08:47:55.157 回答