How to disable scrolling feature in multiline syntax editor

SyntaxEditor for WPF Forum

Posted 10 years ago by Jaroslav Nečas
Version: 14.2.0610
Avatar

Hello,

I am using a multiline syntax editor with auto height and auto width to get all content is always visible. But when I use mouse wheel or selection to last character, editor scrolls down and some lines disappear. What is the easiest way to disable scrolling in mentioned case?

Thanks

Comments (5)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Sorry but I don't believe there is an option to disable scrolling in that scenario.  You might have better luck going into single line edit mode but with word wrap and view line measuring enabled, as seen in the bottom example of our Single-Line Mode QuickStart. 


Actipro Software Support

Posted 10 years ago by Jaroslav Nečas
Avatar

Hello,

thanks for the help. I tried it according to mentioned example, but editor is not able to show text containing newline characters. And also there is no support for creating newline in editor by pressing Enter key.

Is there any other way how to archieve described feature?

Thanks

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you want to reply with some XAML that we could plug into a Window so that we can see the problem scenario, we can have a look and see if we can think of anything else.  But other than what was suggested, I'm not sure there's anything else that is available to help with this.


Actipro Software Support

Posted 10 years ago by Jaroslav Nečas
Avatar

Hello,

I have attached a simple XAML example.

As you can see, even if all lines are visible, mouse wheel can scroll to position where just last line is visible. I would like to disable the scrolling when entire content fits into frame.

Thanks

 

<Window x:Class="ActiproDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syntaxeditor="http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor"
        Title="MainWindow" Height="350" Width="525">
  <Grid>
    <Grid.Resources>
      <Style TargetType="syntaxeditor:SyntaxEditor">
        <Setter Property="AllowDrag" Value="True" />
        <Setter Property="AllowDrop" Value="True" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Margin" Value="6 4 4 4" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="CanSplitHorizontally" Value="False" />
        <Setter Property="CanSplitVertically" Value="False" />
        <Setter Property="MinWidth" Value="200" />
        <Setter Property="IsMultiLine" Value="True" />
        <Setter Property="WordWrapMode" Value="Word" />
        <Setter Property="IsIndicatorMarginVisible" Value="False" />
        <Setter Property="IsLineNumberMarginVisible" Value="False" />
        <Setter Property="IsSelectionMarginVisible" Value="False" />
        <Setter Property="IsOutliningMarginVisible" Value="False" />
        <Setter Property="IsRulerMarginVisible" Value="False" />
        <Setter Property="IsViewLineMeasureEnabled" Value="True" />
        <Setter Property="IsMouseWheelZoomEnabled" Value="False" />
        <Setter Property="IsDefaultContextMenuEnabled" Value="False" />
        <Setter Property="IsTextDataBindingEnabled" Value="True" />
        <Setter Property="Text" Value="Stuff on line 1&#x0a;Stuff on line 2&#x0a;Stuff on line 3&#x0a;Stuff on line 4" />
      </Style>

    </Grid.Resources>

    <syntaxeditor:SyntaxEditor x:Name="SyntaxEditor" />

  </Grid>
</Window>
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thanks for the sample.  The problem here is that you want the SyntaxEditor.CanScrollPastDocumentEnd property to be false, which it is by default.  However you have word wrap on here and per the remarks for that property: "This property has no effect when word wrap mode is active."

The reason is a bit complex.  Basically all our view lines are virtualized so we don't know the "layout" of lines that aren't currently visible in the editor.  While CanScrollPastDocumentEnd = false, and when calculating the maximum scrollbar value for non-wordwrap mode, we can say it is the last line minus the visible line count.  That ensures that you can't scroll past the visible lines.  However when in word wrap mode, we have to adjust the scrollbar based on the percentage of offsets through the document length.  Since we don't have the entire document line layouts stored, we don't consistently know how many offsets near the end of the document to subtract to ensure that you can't scroll past the end of the document.  That's why the property has no effect when word wrap mode is on, such as in your situation.

I would recommend perhaps disabling mouse wheel scrolling by handling preview mouse wheel events.  That will help with the mouse wheel portion.  As long as the editor is large enough, I'm not seeing the the caret at the end scrolling.  How do you repro that?


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.