Posted 14 years ago by Samuel Amoser
Version: 9.1.0505
Avatar
Hi

Using WordWrapMode="None", the horizontal scrollbar is always visible and enabled, even if the text on the line is smaller than the editors text area width. Is it possible to hide the scrollbar as long it is not needed?

samivel.

Comments (11)

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

Sorry but at this time there aren't any options to hide the scrollbar. We may add capabilities for that in the future.


Actipro Software Support

Posted 14 years ago by Samuel Amoser
Avatar
I don't think it's important, but it would be nice.
I'm used to have this behaviour from web browsers, but e.g. MS Word doesn't have it as well.

samivel.
Posted 14 years ago by Jon von Gillern
Avatar
Consider this post a vote to make the horizontal scrollbar hidden when the text doesn't go past the bounds of the syntax editor.

My app lets users type smaller (5-8 line) queries, so the extra 15 vertical pixels would be nice to have available.
Posted 13 years ago by Matt Yaeger
Avatar
Is this true also for the vertical scrollbar? I'd like it to be hidden if it's not needed
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Matt,

Sorry but yes, we don't have options to turn off scrollbars yet. It's on the TODO list and we'll post here when it does get implemented in the future.

In the meantime you may be able to walk the visual tree to look for Scrollbars and hide them or their containing grid column yourself.


Actipro Software Support

Posted 13 years ago by Harri Koppel
Avatar
We need an ability to turn off the vertical scrollbar.
Attached property ScrollViewer.VerticalScrollBarVisibility does not seem to have any effect.

We're also using themed scrollviewer (custom scrollbars) in the rest of the app - this one scrollbar looks very out of place - an ability to toggle the scrollbar and applying a style for it would be most appreciated.

While you guys have it in the TODO list - is there a xaml control template available for the SyntaxEditor control? - we might be able to modify it to achieve the desired result.

Cheers,
Harri Koppel
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Harri,

Sorry it's still on the TODO list at this time. The ScrollBars are defined in code but you might be able to define an implicit style for ScrollBar within SyntaxEditor.Resources to set their Visibility off or Width/Height to 0. Either that or walk the visual tree as previous suggested for a workaround.

We use the standard WPF ScrollBars within SyntaxEditor so any implicit styles you apply to ScrollBar should be picked up fine.


Actipro Software Support

Posted 13 years ago by Kasper
Avatar
I would like to add a vote for this feature as well. I would like to be able to have the scrollbars hidden until they are actually needed. This works very well in SE for WinForms, with the ScrollBarType property :)

Update: Okay, for this specific purpose, I could actually get away with just using the Word WordWrapMode, which got rid of the horizontal scrollbar. That was enough for this situation, so while I still think this is a good idea to get implemented, it's not as important as I first figured. Sorry for that :)

[Modified at 09/20/2011 03:20 AM]
Posted 12 years ago by Keith Rome
Avatar
I also ran into this problem. In my case, I need a single-line editor. I understand this is already implemented in the next release cycle, but I cannot delay until then. I was able to get it down to one-line using WordWrapMode and KeyDown handling, but the scrollbars were still there.

I first tried the suggestion of using an implicit style resource to collapse the scrollbars. This made them hidden but just left some empty space instead (which isn't any better).

I ended up using Snoop to dig into the visual tree and figure out the structure here. Since those scrollbars (and a corner box) are embedded in a Grid, simply collapsing them is not enough. I was however able to write a simple control that inherits from SyntaxEditor and hacks through the visual tree to fully hide the scrollbars.

Your mileage may vary. Also, if the visual tree structure changes at all then this code might break. Then again, it shouldn't be needed after the next release:

    internal class SingleLineSyntaxEditor : ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor
    {
        private static TChild[] GetChildren<TChild>(DependencyObject parent) where TChild : DependencyObject
        {
            var list = new List<TChild>();
            var cnt = VisualTreeHelper.GetChildrenCount(parent);
            for (var ix = 0; ix < cnt; ix++)
            {
                var child = VisualTreeHelper.GetChild(parent, ix) as TChild;
                if (child == null)
                    continue;
                list.Add(child);
            }
            return list.ToArray();
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var adorner = GetChildren<AdornerDecorator>(this).FirstOrDefault();
            if (adorner == null)
                return;
            var outerBorder = adorner.Child;
            if (outerBorder == null)
                return;
            var viewHost = GetChildren<EditorViewHost>(outerBorder).FirstOrDefault();
            if (viewHost == null)
                return;
            var view = GetChildren<EditorView>(viewHost).FirstOrDefault();
            if (view == null)
                return;
            var outerGrid = view.Content as Grid;
            if (outerGrid == null)
                return;
            var innerGrid = GetChildren<Grid>(outerGrid).FirstOrDefault();
            if (innerGrid == null)
                return;
            var allOuterGridChildren = GetChildren<UIElement>(outerGrid);
            var peers = allOuterGridChildren.Except(new[] {innerGrid}).ToArray();
            foreach (var peer in peers)
            {
                peer.SetValue(VisibilityProperty, Visibility.Collapsed);
            }
            innerGrid.SetValue(Grid.RowProperty, 0);
            innerGrid.SetValue(Grid.ColumnProperty, 0);
            innerGrid.SetValue(Grid.RowSpanProperty, 4);
            innerGrid.SetValue(Grid.ColumnSpanProperty, 4);
        }
    }
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

Thanks for the post. Yes, single-line mode is all ready for version 2011.2. We probably still have a couple weeks or so left of work on non-SyntaxEditor 2011.2 features before we can release it.


Actipro Software Support

Posted 12 years ago by Keith Rome
Avatar
Looking forward to it. This issue was the final touch-up needed for a debugger UI that we have been working on.

Once the 2011.2 release ships we will probably adopt it immediately, but I needed this one thing fixed before then (the "Immediate REPL Prompt" in our UI was unusable with scrollbars hiding the content).
The latest build of this product (v24.1.2) was released 4 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.