gpt4 book ai didi

c# - 在 AddNew 或 EditItem 事务期间不允许延迟刷新

转载 作者:太空宇宙 更新时间:2023-11-03 21:23:04 25 4
gpt4 key购买 nike

我有一个包含 2 个数据网格的窗口。如果我从第一个 DataGrid 中的一个特定列单击到另一个 DataGrid 的任何列,则会出现错误

DeferRefresh is not allowed during an AddNew or EditItem transaction

这里出了什么问题?

第一个DataGrid是

<DataGrid x:Name="FirstDataGrid"
ItemsSource="{Binding Parts, Mode=TwoWay}"
SelectedItem="{Binding SelectedPart, Mode=TwoWay}"
CellEditEnding="DataGrid_OnCellEditEnding" >
<i:Interaction.Behaviors>
<views:ScrollIntoViewBehavior />
</i:Interaction.Behaviors>
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown"></EventSetter>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Identifications, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5,0,0,0">
<Hyperlink NavigateUri="{Binding ArticleNumber, Mode=OneWay}"
Command="{Binding ElementName=PartDataGrid, Path=DataContext.OpenIdentificationCommand}" CommandParameter="{Binding}" >
<TextBlock Text="{Binding ArticleNumber, Mode=OneWay}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>

第二个 DataGrid 无关紧要,因为我可以单击任何列来产生错误。

最佳答案

自己解决了。

导致问题的列是只读的。那么为什么还要允许编辑模式呢?那显然是错误的。我通过添加

解决了这个问题
IsReadOnly="True"

到 WPF 列定义。

关于c# - 在 AddNew 或 EditItem 事务期间不允许延迟刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29319406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com