Prevent Automatic Horizontal Scroll in TreeView

前端 未结 8 973
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 06:41

Whenever a node is selected in my treeview, it automatically does a horizontal scroll to that item. Is there a way to disable this?

8条回答
  •  情话喂你
    2020-12-14 07:08

    I managed to solve the problem using the following:

    
       
          
             
          
       
    
    

    I bind the width of the StackPanel which renders the ItemsPanel here, to the ActualWidth of ContentPresenter in the TreeView.

    It also works nice with the "hacked" Stretching TreeView by: http://blogs.msdn.com/b/jpricket/archive/2008/08/05/wpf-a-stretching-treeview.aspx (I modified that solution not to remove grid column, but to change Grid.Column property of the first Decorator element from 1 to 2).

提交回复
热议问题