Ticket Q257530
Visible to All Users

Add the capability to resize control based on own content size

created 15 years ago

Hello,
I have a document(with pictures, text,…) loaded in a richeditcontrol. I must to show a preview of the document in the following way:
- if my document contains just a few rows, the richeditcontrol should be resized to have visible just my rows, nothing more (the empty area after the end of the document should be not visible, please see the attached pictures).
Is this possible to achieve? Can the RichEditControl library provide information to calculate this size?
Thank you,
L.

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hello,
The new AutoSizeMode property is available for the RichEditControl component. This property can be set to any of the following values:
Both,
Horizontal,
Vertical,
None
I have attached a sample project to demonstrate how this property affects the layout of a RichEditControl instance.
I hope you will find this information helpful.

    Comments (2)
    MB MB
    Matthias Burtscher 10 years ago

      The auto sizing feature of the RichEdit control works fine but it seems to be very buggy when used in combination with different  LayoutControl situations. Let's say we'd like to create a messaging module. On top we have a grid (or banded grid or something different) that shows existing messages. At the bottom I'd like to put a auto-sizing RichEdit control to reply to the current conversation.
      You can see a screenshot attached where I have modified your example in this way. The LayoutControl does not adapt to the RichEdit control's changed size + When adding text into the RichEdit control it grows beyond the window border at the bottom.

      DevExpress Support Team 10 years ago

        Hello,

        To process your recent post more efficiently, I created a separate ticket on your behalf: T202601: A RichEditControl is not sized property in a LayoutControl. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

        Other Answers

        created 15 years ago (modified 11 years ago)

        Hi ,
        At present, XtraRichedit doesn't have built-in support for this functionality. However, I agree with you that it would be great to implement this feature. I've registered a corresponding suggestion in our database, and we'll consider implementing it in the future.
        Thanks,
        Elliot

          Show previous comments (77)
          DevExpress Support Team 8 years ago

            Hello Levente,

            The auto size feature is not supported in WPF RichEditControl for now. We have plans to implement this functionality for WPF RichEditControl as well. However, I cannot provide you with any estimates in this case because of the complexity of this task. We will update the The AutoSizeMode property doesn't work thread once we have any progress with this feature.  I recommend you add that ticket to your Favorites (click the "Add to Favorites" button on that ticket's page) to be automatically notified when the auto sizing functionality is implemented out of the box.

            I'm afraid I can't suggest any suitable workaround to support the "Auto Size" feature in WPF RichEditControl using the current architecture of the control.

              Hello,

              Thank you for your answer.
              For my case (I have to display a not editable preview) I found a workaround, which seems to work:

              1. in xaml I set a huge initial height (Height="50000") for the RichEditControl to try to make sure that the full document content can be fully displayed -> this will force the control that all the SimpleViewPages will be created
              2. calculating the sum. of the SimpleViewPages will give the content height:

              static double CalcRichEditHeightBasedOnContent(RichEditControl richEditControl)
              {
              double calculatedHeight = 0;

              var oneSimpleViewPage = LayoutHelper.FindElementByType<SimpleViewPage>(richEditControl);
              var simpleViewPagesParent = oneSimpleViewPage.Parent;

              int childrenCount = VisualTreeHelper.GetChildrenCount(simpleViewPagesParent);
              for (int i = 0; i < childrenCount; i++)
              {
              var child = VisualTreeHelper.GetChild(simpleViewPagesParent, i);
              var simpleViewPage = child as SimpleViewPage;
              if (simpleViewPage != null)
              {
              calculatedHeight += simpleViewPage.ActualHeight;
              }
              }

              return calculatedHeight;
              }

              This solution works, but I don't like that I have to set the initial big height for the RichEditControl. Better would be just to simply calculate the sum of the SimpleViewPages.
              If I understand well the inner behavior of your control, it uses virtualization -> so the visual tree contains only one or two SimpleViewPages, instead of all of them.
              My question would be: is it possible to disable virtualization on RichEditControl as configuration? Would it work like that? it anyway doesn't make sense when the full content must to be displayed.

              Thank you,
              Levente

              DevExpress Support Team 8 years ago

                Thank you for providing your code, Levente. As far as I understand the task, you wish to calculate the height of the RichEditControl's content and resize the control to the calculated value.

                If so, I recommend you use our Layout API feature rather than iterating though the RichEditControl's visual tree to obtain the content's height. We recently discussed this task in the Ability to resize the RichEditContlol based on its content within the LayoutControl thread. You can find a sample project and a video illustrating how this sample operates in the attachment to that thread.

                Should you have any questions or concerns while implementing this approach, please create a separate ticket and describe them there. We will do our best to assist you.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.