开发者

Prevent Automatic Horizontal Scroll On Selected TreeView Item

开发者 https://www.devze.com 2023-04-03 10:08 出处:网络
When a TreeViewItem is selected, the horizontal and vertical scrollbars adjust so it开发者_开发技巧\'s in view.I like the vertical scrollbar behavior, but I want to stop the horizontal one.Disabling t

When a TreeViewItem is selected, the horizontal and vertical scrollbars adjust so it开发者_开发技巧's in view. I like the vertical scrollbar behavior, but I want to stop the horizontal one. Disabling the horizontal scrollbar has no effect.


Try using the ScrollViewer.HorizontalScrollBarVisability and setting it to Disabled.

<TreeView Width="100" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <TreeViewItem Header="This is a very long header with a small width..................123"/>
    </TreeView>


This may guide you ...

Key is to handle BringIntoView event at tree view item level before scrollviewer receives it.

0

精彩评论

暂无评论...
验证码 换一张
取 消