ScrollViewer Theme with AvalonEdit Control

4 posts, 0 answers
  1. Zach
    Zach avatar
    2 posts
    Member since:
    Mar 2013

    Posted 06 May 2013 Link to this post

    When I put in a scrollViewer Theme like
    <Style TargetType="ScrollViewer">
            <Setter Property="t:StyleManager.Theme" Value="{StaticResource Theme}" />

    Then I put in a simple AvalonEdit Control into the Grid, I have to place the cursor in the very first character of the first line to be able to select the text box. How can I get around this? I would like to be able to use the Nice looking scroll viewer with the Editor. Ideally it would be nice if Telerik had a radtextbox with Line numbers and Syntax Highlighting.

    <avalonEdit:TextEditor Margin="5" Grid.Row="2" Width="Auto" FontFamily="Segoe UI" FontSize="10pt" SyntaxHighlighting="C#" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" ShowLineNumbers="True">

  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 09 May 2013 Link to this post


    TextEditor control is not a control provided by Telerik.  As to the control you need, you can check if any of the controls we suggest would be suitable for you on the WPF Demos.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. Hans
    Hans avatar
    13 posts
    Member since:
    Feb 2013

    Posted 17 Jun 2014 Link to this post

    I had a look at the source code of the TextEditor control on CodeProject. The template of this control contains a ScrollViewer. The ScrollViewer has its HorizontalContentAlignment and VerticalContentAlignment properties set to 'Left' and 'Top'. If you change these values to 'Stretch' the control seems to work fine.

    I did this myself by taking the original control template from CodeProject, and modifying these two properties as needed. This results in the code below. The below style sits inside a resource dictionary that I've created and I reference it in my App.xaml after theTelerik Themes. I'm using Implicit Styles though, you seem to be using the StyleManager (which I would not recommended).

                        TargetType="{x:Type avalonEdit:TextEditor}">
                            VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"
                            HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
                            Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" />
                                    Value="Disabled" />
  5. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 18 Jun 2014 Link to this post


    Thank you for your input.

    You can also refer to Setting a Theme (Using Implicit Styles) article where you can find detailed explanation and an example on how to use Implicit Styles.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top