Hello!
I am using xamRichTextEditor for a TextChat with avatars. I cannot figure out how scroll down after TextInput.
Second thing: Is possible to detect if user is scrolling up to first line? (trying implement history load like in Skype, when we scorlling up older and older history is loading)
Please for assistance.
First part I mostly manage with code:
internal void ScrollDown() { const RichTextEditorCommandType type = RichTextEditorCommandType.MoveToEndOfDocument; var cmd = new RichTextEditorCommand(type); cmd.Execute(RichTextBox); }but it's not perfect solution. Text its scrolling only to top of last paragraph
but not at bottom
There left 1 mouse scroll down of space. Any idea how to fix it?
Hello Artur,
I have been looking into your requirements. If I understood correctly your first question you need to submit some content in the XamRichTextEditor via a button or other command and you need to ensure that the last submitted content is visible. What I can suggest in order to achieve this functionality is setting the VerticalViewOffset property of the XamRichTextEditor’s ActiveDocumentView object to the offset of the last paragraph available in the editor. The code will look similar to the following:
var paragraphs = document.GetParagraphs(DocumentSpan.All);
if (paragraphs != null && paragraphs.Count() > 0)
xamRichTextEditor1.ActiveDocumentView.VerticalViewOffset = paragraphs.LastOrDefault().GetDocumentSpan().Offset;
Regarding the second part of your requirements, I believe the best way would be to use our Utilites class’ GetDescendantFromType method in order to get the scrollbar of the XamRichTextEditor. Then you can subscribe to its ValueChanged event and insert the older paragraphs when certain conditions are fulfilled.
Both of the described approaches are implemented in the sample application I am attaching for your reference. If you have any further questions on this matter, please do not hesitate to let us know.
Thank you for using Infragistics Components.
We have shipped out a new service release where your issue is resolved. I'd be glad to find out if you had tested it out and if it had met your requirements.You can download the Service Releases by logging to our web site and going to Account\My Keys and Downloads page.
Thank you for your email. I investigated the described behavior and I believe that the scrollbar thumb jumping is an issue in the XamRichTextEditor because the jumping happens even when the logic for inserting content is disabled. I have logged it in our internal tracking system with a Development ID of 211003. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution. I will leave this case open and update you with this information after the review. You can also continue to send updates to this case at any time.
You can view the status of all development issues connected to this case from the "Development Issues" tab, when viewing this case on the "Account\Support Activity" page of our website.
With regard to implementing a behavior similar to Skype's history loading mechanism in addition to the jumping issue I believe you might need to ensure that a particular line remains at the top of the view after loading some content before it. If you would like to do so I can recommend you suggest a new product idea for such a feature. New Product Ideas for future versions can be suggested at http://ideas.infragistics.com.
Steps to create your idea:
1. Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).
2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
3. Add your product idea and be sure to be specific and provide as much detail as possible.
• Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
• [CASE: “Reference case [case number], FORUMS: “Include a link to this thread”] in your idea so product management will be able to look back at this case.
The benefits of submitting the product idea yourself include:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
Thank you for choosing Infragistics.
Hello Galina,
Thank you for answer, yes its work but not always. Anyway i found solution for this.
_scrollBar.Value = _scrollBar.Maximum;
Other problem came up. When we are scrolling up and loading data from other sources e.g DataBase, ScrollBar is jumping up and down sometimes not even reaching top. I found that VerticalViewOffest is set couple times by some component ( ScrollBar_ValueChanged () fires few times w/o RTE_Contact_MouseWheel fire) so its changed by something else then user input.
I tried fix this by membering previous scrollbar position and move it there when scroll want to jump but its not satisfied solution
I modyfied your sample to reproduce problem.
I identified the problem with the document offset. When I set the VerticalViewOffset to the last paragraph's offset the view is scrolled to the beginning of this last paragraph which, you are absolutely right, is not the end of the document. What I changed and think will work is adding the length of the last paragraph to its offset as follows:
{
var last = paragraphs.LastOrDefault().GetDocumentSpan();
RTE_Contact.ActiveDocumentView.VerticalViewOffset = last.Offset + last.Length;
}
Please, let me know if this approach works in your scenario.
Actually I manage to make it work. I moved code from ScrollBar_ValueChanged to RichTextBox_MouseWheel and works perfect.
Going back to scrolling down, your solution doesnt work as expected.
paragraphs.LastOrDefault().GetDocumentSpan().Offset return incorrect end of document offset ( its point 3/4 of document)
I found correct value in xamRichTextEditor.ActiveDocumentView.ScrollManager.VerticalScrollBar.Maximum
but its private property. any chance to retreive it?
Thanks for help