0

在此处输入图像描述

我有 2 个数据网格单击我在其他数据网格中添加项目但是当我单击滚动条拇指或轴多次滚动它时在其他数据网格上添加项目请帮助我

这是代码

                    <DataGrid Name="dgMenu" Grid.Row="1" Grid.RowSpan="4" Margin="5,0,0,0" AutoGenerateColumns="False" RowHeight="25"  AlternatingRowBackground="{StaticResource AlternateRowBackgroundBrush}" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
              HeadersVisibility="Column" SelectionUnit="FullRow" ItemsSource="{Binding DgMenuCollection,Mode=TwoWay}" SelectedItem="{Binding DgSelectedMenu,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" PreviewKeyUp="dgMenu_PreviewKeyUp"
              VerticalGridLinesBrush="{StaticResource GridLineColorBrush}" HorizontalGridLinesBrush="{StaticResource GridLineColorBrush}" Grid.Column="0" Grid.ColumnSpan="2" MouseDoubleClick="dgMenu_MouseDoubleClick">
                        <DataGrid.Resources>
                            <Style TargetType="{x:Type DataGridCell}">
                                <Style.Triggers>
                                    <Trigger Property="DataGridCell.IsSelected" Value="True">
                                        <Setter Property="Background" Value="{StaticResource ButtonSelectedBrush}"  />
                                        <Setter Property="BorderBrush" Value="#A8E3FC" />
                                        <Setter Property="Foreground" Value="Black" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.Resources>
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Code" Binding="{Binding PN_Recipe.RecipeCode}" />
                            <DataGridTextColumn Header="Recipe Name" Binding="{Binding PN_Recipe.RecipeName}"/>
                            <DataGridTextColumn Header="RecipeHalf Price" Binding="{Binding HalfMenuCost}" Visibility="Collapsed"  />
                            <DataGridTextColumn Header="MenuFull Price" Binding="{Binding FullMenuCost}" Visibility="Collapsed"/>
                        </DataGrid.Columns>
                    </DataGrid>
4

1 回答 1

0

我认为问题是因为PreviewKeyUp="dgMenu_PreviewKeyUp"您可以使用鼠标双击事件来添加项目,而不是使用 PreviewKeyUp。

如果我弄错了,我很抱歉。

问候

于 2012-11-20T15:23:26.927 回答