当记录发生更改时,我需要在我的 ListView 中显示新旧值。我的意思是每个单元格都应该显示新值和旧值。现在我正在这样做:
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding MyValue}"/>
<TextBlock Margin="7,0,0,0" Text="{Binding old.MyValue}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
对于下一列,它将是:
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding MySecondValue}"/>
<TextBlock Margin="7,0,0,0" Text="{Binding old.MySecondValue}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
但是我有 10 列,对于所有 10 列进行大量复制粘贴并不是那么有趣。
有什么想法可以做得更紧凑、更好吗?
我想要的理想变体是这样的:
<GridViewColumn.CellTemplate>
<DataTemplate>
<MySpecialWhatever NewValueText="{Binding MyValue}" OldValueText="{Binding old.MyValue}" >
</MySpecialWhatever>
</DataTemplate>
</GridViewColumn.CellTemplate>