简体   繁体   English

WPF RichTextBox触摸滚动不起作用

[英]WPF RichTextBox Touch Scrolling doesn't work

I have a rich text box control, that I wish to be able to scroll by touch. 我有一个富文本框控件,希望能够通过触摸进行滚动。

The MSDN documentation says I should set this property: https://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.panningmode(v=vs.110).aspx MSDN文档说我应该设置此属性: https : //msdn.microsoft.com/zh-cn/library/system.windows.controls.scrollviewer.panningmode(v=vs.110).aspx

<RichTextBox ScrollViewer.PanningMode="Both" >

However, this makes no difference, touch events still select text and instead of scrolling. 但是,这没有什么区别,触摸事件仍会选择文本,而不是滚动。 Any ideas? 有任何想法吗?

So creating a scrollable object is a bit tricky in WPF. 因此,在WPF中创建可滚动对象有些棘手。 You need to put the RichTextBox inside the ScrollViewer . 您需要将RichTextBox放入ScrollViewer Then you need to set the PanningMode to either horizontal or vertical (or you can try to set it to auto which is also recommended). 然后,您需要将PanningMode设置为horizontalvertical (或者也可以尝试将其设置为auto,这也是建议的设置)。 For example you should get something like this: 例如,您应该获得如下内容:

<ScrollViewer CanContentScroll="True" PanningMode="VerticalOnly">
            <RichTextBox> 
                       //content here
            </RichTextBox>
</Scrollviewer>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM