滚动条自动下降 [英] ScrollBar is automatically going down
问题描述
我有 我正在将控件动态绑定到我的项目控件.
I am binding the controls dynamically to my items control.
我的滚动条第一次显示第一个位置.
First time my scroll bar showing the first position.
如果我再次打开该窗口,则该窗口将显示在控制焦点的中间或最后位置.
If I open the window again, it is showing in middle or last focused control position.
如何使滚动条到达起始位置?
How to get the scrollbar to starting position?
推荐答案
您可以执行的列表框:
For a listbox you can do:
if (lb.Items.Count > 0)
{
lb.ScrollIntoView(lb.Items[0]);
}
您可以重构为使用列表框,而不是使用列表框内的itemscontrol和scrollviewer.
You could re-factor to use a listbox rather than itemscontrol and the scrollviewer inside the listbox.
您可以使用如下所述的样式删除选择背景:
You can remove the selection background using a style as explained here:
http://social.technet.microsoft.com /wiki/contents/articles/29777.wpf-property-list-editing.aspx
当您说再次打开窗口"时,大概这不是在重新实例化窗口.在普通项目控件中没有选定的项目,因此我认为任何状态保留都必须在窗口中.
When you say "open the window again" this is presumably not re-instantiating the window. There is no selected item in a plain itemscontrol so I would think any retention of state must be in the window.
您可以重新实例化.
这篇关于滚动条自动下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!