Ticket T114752
Visible to All Users

The AutoSizeMode property doesn't work

created 11 years ago
Show previous comments (24)

    We also need this feature working.
    The workaround above is half working. You should actually check all the siblings of that first SimpleViewPage, find their location in relation to their parent and add the size. Take the Max of these siblings and you have your height.
    Something like this (the richEditControl1 box is within a groupbox(this) for me):
           public void PerformAutoHeight()
           {
               Dispatcher.BeginInvoke(new Action(async () =>
               {
                   if (richEditControl1.VerticalScrollPosition != 0) SetVerticalScrollbarPosition(0);
                   await Task.Delay(10);
                   var sv = FindChild<SimpleViewPage>(richEditControl1);
                   var parent = sv.Parent as Canvas;
                   var maxH = sv.Height;
                   foreach (var child in parent.Children)
                   {
                       var tb = child as Control;
                       if (tb != null)
                       {
                           UIElement container = VisualTreeHelper.GetParent(tb) as UIElement;
                           Point relativeLocation = tb.TranslatePoint(new Point(0, 0), container);
                           var top = relativeLocation.Y + tb.ActualHeight;
                           maxH = Math.Max(top, maxH);
                       }
                   }
                   Height = maxH + 50;
               }));
           }
         private void SetVerticalScrollbarPosition(int pos)
           {
               if (richEditControl1.VerticalScrollBar != null)
               {
                   richEditControl1.VerticalScrollBar.Value = pos;
                   dynamic scrollbar = richEditControl1.ActiveView.GetType().InvokeMember("VerticalScrollController", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty, null, richEditControl1.ActiveView, null);
                   scrollbar.UpdateScrollBar();
                   scrollbar.ScrollToAbsolutePosition(0);
                   richEditControl1.ActiveView.GetType().InvokeMember("OnVerticalScroll", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, richEditControl1.ActiveView, null);
                   this.Refresh();
               }
           }

    PK PK
    Patrick Kern 1 8 years ago

      Hi,

      we still need this feature. is it completed?
      thanks

      DevExpress Support Team 8 years ago

        Hi Patrick,

        Our current attempts to fix this issue were unsuccessful. So, most probably, we will postpone this task for the current release.

        I would like to note that we introduced the Layout API feature for RichEditControl in v15.1 (Add a corresponding API that allows analyzing Document Model layout). The main entry point of the Layout API is the RichEditControl.DocumentLayout property. This property provides access to the DocumentLayout object containing basic properties and methods for working with document layout objects.

        It is possible to use this functionality to calculate the RichEditControl height and implement the auto-height feature for RichEditControl in a custom manner. You can find a sample that shows this approach in the Ability to resize the RichEditContlol based on its content within the LayoutControl ticket. I hope you will find this information and sample useful.

        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.