私が持っているのは次のすべてですDataGrid
<DataGrid x:Name="resourceDataGrid"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AutoGenerateColumns="false"
GridLinesVisibility="None"
RowHeaderWidth="0"
CanUserAddRows="True"
CanUserDeleteRows="True"
ItemsSource="{Binding Path=Resources,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged,
IsAsync=True}">
<DataGrid.Columns>
<DataGridTextColumn Header="KeyIndex" Binding="{Binding KeyIndex}" IsReadOnly="True"/>
<DataGridTextColumn Header="FileName" Binding="{Binding FileName}" IsReadOnly="True"/>
<DataGridTextColumn Header="ResourceName" Binding="{Binding ResourceName}" IsReadOnly="False"/>
<controls:CollectionTextColumn Collection="ResourceStringList" Visibility="Collapsed"/>
</DataGrid.Columns>
</DataGrid>
データセットの行が削除されたときに、列の番号を付け直したいKeyIndex
。この再番号付けが行われると、更新されたセルをエレガントにフラッシュして、これらの値が更新されたことをユーザーに知らせたいと思います。
私はまだWPFとMVVMに比較的慣れていないため、この値の変化を「聞く」方法がわかりません。私が最初に考えたのは、DependencyProperty
この仕事には new は必要なく、 aSourceUpdated
を使用してプロパティに接続するだけでこれを行うことができるというDataTrigger
ことでしたが、これを行う方法は明確ではありません。私は以下を定義しようとしました
<Style x:Key="readOnlyCellUpdatedStyle"
TargetType="{x:Type DataGridCell}"
BasedOn="{StaticResource {x:Type DataGridCell}}">
<Style.Triggers>
<DataTrigger Binding="ContentUpdated" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.25"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
しかしContentUpdated
、ViewModel 内の各項目のプロパティへのバインドは、理想とはほど遠いものです。私がやりたいことをする正しい方法は何ですか?
御時間ありがとうございます。