2012-11-06 100 views
0

我想改變一個燒毛單元格的背景在數據網格當源被更新。我使用MVVM,C#和WPF:動畫背景更新

這裏是我不工作的代碼構成的XAML文件(僅DATACELL本身):

<DataGridTextColumn x:Name="test" Header="Errors" IsReadOnly="True" Binding="{Binding ErrorsReceived}"> 
    <DataGridTextColumn.CellStyle> 
        <EventTrigger RoutedEvent="Binding.SourceUpdated"> 
         <BeginStoryboard> 
          <Storyboard> 
           <DoubleAnimation Storyboard.TargetName="test" 
              Storyboard.TargetProperty="Background" 
              From="Red" 
              To="White" 
              Duration="0:0:0.2"/> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger> 
       </DataGridTextColumn.CellStyle> 
      </DataGridTextColumn> 

我怎樣才能使這項工作?

回答

1

還沒有機會來運行它尚未但是你已經嘗試設置樣式不被限定的風格,和你想用動畫雙動畫色彩,嘗試這樣的事情。

<DataGridTextColumn Header="Errors" IsReadOnly="True" Binding="{Binding ErrorsReceived}"> 
      <DataGridTextColumn.CellStyle> 
       <Style> 
        <Style.Triggers> 
         <EventTrigger RoutedEvent="Binding.SourceUpdated"> 
           <BeginStoryboard> 
            <Storyboard> 
             <ColorAnimation Storyboard.TargetProperty="Background" From="Red" To="White" Duration="0:0:0.2"/> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
         </Style.Triggers> 
       </Style> 
      </DataGridTextColumn.CellStyle> 
    </DataGridTextColumn >