本文介绍了DataGrid中的SelectedIndex。滚动期间的值为-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带滚动的dataGrid。

I have a dataGrid with a scroll.


网格被抛入一个高度为6的StackPanel来自DataGrid的行是可见的。

Grid is thrown into a StackPanel of such height that 6 lines from DataGrid are visible.


每行都有一个具有不同项目数的ComboBox。如果dataGrid中的行多于8,则在使用滚动时,当鼠标位于DataGrid上方时,SelectedIndex将更改为-1。对于不同的ComboBox位置,这会随机发生。

Each row has a ComboBox with different number of items. If there are more lines in dataGrid than 8 then when using the scroll, when the mouse is above the DataGrid, SelectedIndex changes to -1. This happens randomly for different ComboBox positions.


仅当行数超过8行时才会出现这种情况。

The situation only occurs when there are more than 8 rows.


我可以阻止如下降到0以下,但这不是断开连接。这会导致其他问题。

I can block as below descending below 0 but this is not a disconnect. This causes other problems.

public int SelectedIndex
        {
            get { return _SelectedIndex; }
            set
            {
                _SelectedIndex = (value >= 0) ? value : 0;
                Console.WriteLine("SelectedIdx: " + value);
                //_SelectedIndex = value;
                OnPropertyChanged("");
            }
        }




任何有类似问题的人都可以见面吗?



Can anyone with a similar problem meet?

推荐答案

同样看到一些XAML会有所帮助,因为StackPanel不会限制它内容到它的高度。

Also seeing some XAML would help as a StackPanel does not restrict its content to its height.


这篇关于DataGrid中的SelectedIndex。滚动期间的值为-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 04:50