我在wpf中有以下DataGrid。
<DataGrid AutoGenerateColumns="False" Grid.Row="1" Name="adsGrid" ItemsSource="{Binding Path=Ads}" CanUserAddRows="False" CanUserDeleteRows="False" SelectionChanged="adsGrid_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Path=ID}" IsReadOnly="True" />
<DataGridTextColumn Header="File" Binding="{Binding Path=FileName}" IsReadOnly="True" />
<DataGridTemplateColumn Header="Expiration date" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding Path=ExpirationDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Info" Width="100*" Binding="{Binding Path=Info}" />
</DataGrid.Columns>
</DataGrid>
问题是DateTime选择器不会更新相关对象,但会从中读取值。我已经尝试添加Mode = TwoWay,但它没有帮助。其他属性正确更新。
答案 0 :(得分:5)
要调试这个,我会尝试:
DateTime
(不是可空或DateTimeOffset?)UpdateSourceTrigger=PropertyChanged