ScintillaNet strange resizing in WPF Application

825 views Asked by At

I'm want to use some small ScintillaNet Controls in my WPF Application. I've compiled the WPF branch from the ScintillaNet repository. I have added the Scrintilla control:

<UserControl x:Class="LogicEditor.View.ScriptInput"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:scintilla="http://scintillanet.codeplex.com"
         mc:Ignorable="d" 
         d:DesignHeight="63" d:DesignWidth="195">
    <Grid>
        <scintilla:ScintillaWPF HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="_scintilla" />
    </Grid>
</UserControl>

The control looks fine. If I increase the Control the scintilla control also increases but if I reduce the control the scintilla control keeps the size and overlaps the other UI.

I looked to the sample application of ScintillaNet.WPF: SCide.WPF. In this Application all works fine but I cannot see any relevant difference to my code.

I think the resizing and the overlapping are two different issues. I also tried the normal WindowsFormsHost without the WPF wrapper but there I have the same problem.

Can anybody help?

Edit: This only happens when the Scintilla control is in a List

2

There are 2 answers

0
psurikov On

I know this issue is super old but I had the same problem and solved it with a custom panel that minimizes the text editor desired size:

public class ScintillaPanel : Panel
{
    protected override Size MeasureOverride(Size availableSize)
    {
        var children = InternalChildren.OfType<UIElement>();
        var firstChild = children.FirstOrDefault();
        if (firstChild != null)
            firstChild.Measure(new Size(0, 0));
        return new Size(0, 0);
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        var children = InternalChildren.OfType<UIElement>();
        var firstChild = children.FirstOrDefault();
        if (firstChild != null)
            firstChild.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
        return finalSize;
    }
}

And then wrap scintilla control like this:

<local:ScintillaPanel>
    <WindowsFormsHost>
        <scintilla:Scintilla/>
    </WindowsFormsHost>
</local:ScintillaPanel>
1
demonllama On

I know this issue is super old but I wanted to leave a solution here in case anyone else encountered this. It seems that ScintillaNET doesn't like to be hosted inside a WPF ScrollViewer control.

I inadvertently had my WindowsFormHost control being presented by a ContentPresented which was inside (you guessed it) a ScrollViewer. Even disabling/hiding the vertical scrollbar with the ScrollViwer with ScrollBarVisibility didnt work. It wouldn't seem that it has to do with virtualization either since that has to be enabled. Since Scintilla implements its own scrolling the solution is to avoid having ScintillaNET hosted inside any form of ScrollViewer and just let it natively handle its scrolling content.

Your issue is that a List has a ScrollViewer. Get it out of there and it should fix it.