We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

[UWP] Programm Scrolling in sfRichTextBoxAdv

Thread ID:

Created:

Updated:

Platform:

Replies:

130995 Jun 15,2017 07:48 AM UTC Jun 19,2017 04:31 AM UTC UWP 3
loading
Tags: SfRichTextBoxAdv
Democraten
Asked On June 15, 2017 07:48 AM UTC

Hi there! I recently started using your library.
I was most interested in sfRichTextBoxAdv, and I began to "dig" it.
Is it possible to get/set from the code scroll value for him?
Any ideas?

Venkatesan Mani [Syncfusion]
Replied On June 16, 2017 10:20 AM UTC

Hi Democraten,

Thank you for using Syncfusion products.

At present our SfRichTextBoxAdv control does not have API support to perform scrolling. We have already logged this requirement as feature request. We will implement these features in any of our forthcoming releases. We usually have a timeframe of at least three months between releases. The feature implementation would also greatly depend on the factors like product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

Now, as a workaround you can achieve your requirement by writing an extension class for SfRichTextBoxAdv. In that class, you can get the vertical and horizontal scroll bars from the template and then by manipulating it values you can scroll from code behind. We have prepared a sample to demonstrate the same. Please find the sample code and sample below,

Code of Extension class:
C#: 
/// <summary> 
/// Represents the extension class for SfRichTextBoxAdv. 
/// </summary> 
public class SfRichTextBoxAdvExtension : SfRichTextBoxAdv 
{ 
    #region Fields 
    ScrollBar verticalScrollBar; 
    ScrollBar horizontalScrollBar; 
    #endregion 
 
    #region Properties 
    /// <summary> 
    /// Gets or sets the verical scrollbar value. 
    /// </summary> 
    public double VScrollValue 
    { 
        get 
        { 
            if (verticalScrollBar != null) 
                return verticalScrollBar.Value; 
            return 0; 
        } 
        set 
        { 
            if (verticalScrollBar != null) 
                verticalScrollBar.Value = value; 
        } 
    } 
    /// <summary> 
    /// Gets or sets the horizontal scrollbar value. 
    /// </summary> 
    public double HScrollValue 
    { 
        get 
        { 
            if (horizontalScrollBar != null) 
                return horizontalScrollBar.Value; 
            return 0; 
        } 
        set 
        { 
            if (horizontalScrollBar != null) 
                horizontalScrollBar.Value = value; 
        } 
    } 
    /// <summary> 
    /// Gets the vertical scroll bar maximum value. 
    /// </summary> 
    public double VScrollMaxValue 
    { 
        get 
        { 
            if (verticalScrollBar != null) 
                return verticalScrollBar.Maximum; 
            return 0; 
        } 
    } 
    /// <summary> 
    /// Gets the horizontal scroll bar maximum value. 
    /// </summary> 
    public double HScrollMaxvalue 
    { 
        get 
        { 
            if (horizontalScrollBar != null) 
                return horizontalScrollBar.Maximum; 
            return 0; 
        } 
    } 
    #endregion 
 
    #region Constructor 
    /// <summary> 
    /// Initializes the instance of SfRichTextBoxAdvExtension class. 
    /// </summary> 
    public SfRichTextBoxAdvExtension() 
    { 
        // Wires the Loaded event. 
        this.Loaded += SfRichTextBoxAdvExtension_Loaded; 
    } 
 
    #endregion 
 
    #region Events 
    /// <summary> 
    /// Called when SfRichTextBoxAdv is loaded. 
    /// </summary> 
    /// <param name="sender"></param> 
    /// <param name="e"></param> 
    private void SfRichTextBoxAdvExtension_Loaded(object sender, RoutedEventArgs e) 
    { 
        verticalScrollBar = GetTemplateChild("VerticalScrollBar") as ScrollBar; 
        horizontalScrollBar = GetTemplateChild("HorizontalScrollBar") as ScrollBar; 
    } 
    #endregion 
 
    #region Implementation 
    /// <summary> 
    /// Do the vertical scroll. 
    /// </summary> 
    /// <param name="deltaValue"></param> 
    public void DoVerticalScroll(double deltaValue) 
    { 
        if (deltaValue != 0 && verticalScrollBar != null) 
        { 
            double previousValue = VScrollValue; 
            if (previousValue + deltaValue <= VScrollMaxValue) 
                VScrollValue = previousValue + deltaValue; 
            else 
                VScrollValue = VScrollMaxValue; 
        } 
    } 
    /// <summary> 
    /// Do the horizontal scroll 
    /// </summary> 
    /// <param name="deltaValue"></param> 
    public void DoHorizontalScroll(double deltaValue) 
    { 
        if (deltaValue != 0 && horizontalScrollBar != null) 
        { 
            double previousValue = HScrollValue; 
            if (previousValue + deltaValue <= HScrollMaxvalue) 
                HScrollValue = previousValue + deltaValue; 
            else 
                HScrollValue = HScrollMaxvalue; 
        } 
    } 
    /// <summary> 
    /// Disposes the instance. 
    /// </summary> 
    public void Dispose() 
    { 
        verticalScrollBar = null; 
        horizontalScrollBar = null; 
        this.Loaded -= SfRichTextBoxAdvExtension_Loaded; 
        base.Dispose(); 
    } 
    #endregion 
} 

Sample :
http://www.syncfusion.com/downloads/support/forum/130995/ze/Sample_ScrollProgramattically1039990903

Please try the running sample and let us know if this helps you.

Regards,
Venkatesan M. 


Democraten
Replied On June 16, 2017 12:55 PM UTC

Venkatesan M,Thank you very much, excellent answer! It's works. To be honest, at first I wanted to do something like that, but it seemed to me that there is a simpler way. However, it works. Thank you for finding the time and provided the whole project. The question is closed.

Venkatesan Mani [Syncfusion]
Replied On June 19, 2017 04:31 AM UTC

Hi Democraten,

Thank you for your update.

Please let us know if you require any further assistance. We will be happy to assist you.

Regards,
Venkatesan M.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;