Bug Report T316264
Visible to All Users

FloatGroup.SizeToContent doesn't work when WindowsFormsHost is used as the root content

created 9 years ago

Hi,

This question is been asked multiple times in this forum, and I still cant get it to work after following the solutions provided.

My Scenario:
I have an application which uses your docking framework, and we have been ironing out issues one by one for the last 4 months in terms  of docking. The application displays windows which are sized to content and non re-sizable. All of those windows has your Xtra Grid(WinForms) mostly for performance reasons, which means we will have to live with it.

My Issue:

  1. When I create a floating window with an XtraGrid on it, setting the SizeToContent & Resize property does't seem to have any effect. This means most of my windows(let us say we are displaying 20 rows) will appear in a default 200*200  layout with a scroll-bar which is a big let down to users.
  2. When I dock the floating window, it all of a sudden has re-sizing issues. The grid gets centered sometimes and sometimes the layout seems to get cut off. Once re-sized, the scroll-bars does't appear as well.

I have attached a sample using which you can reproduce this. Execute it, and click on the "Add Floating Window" button. This is supposed to bring up a window which is sized to content and not re-sizable which does't work. While docked, it should be re-sizable and the scroll-bar should appear in the grid as and when the panel is re-sized. When floated again, it should go back to the previous floating state which is SizeToContent & Non Resizable.

Please can you advice me how to get this working?

Thanks,
-Thomas

Answers approved by DevExpress Support

created 9 years ago

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

    Show previous comments (12)

      Hi Kirill,
      If I understood your comments correctly, what you are saying is that essentially SizeToContent does't work with XtraGrid hosted inside a WindowsFormsHost . I wonder why was this marked as fixed in the hotfix.
      I'm not sure how this could be achieved anymore. We were overcoming this problem with our Sizing logic inside the xtra grid, to make it size to content - and now the same sizing logic is causing issues while the window is docked.
      Thanks for ticket you have raised, will follow up there.
      Thanks,
      -Thomas

        Kirill:"I tested our LayoutPanel's SizetoContent behavior with WindowsFormsHost with XtraGrid and the default WPF Window's SizetoContent behavior with the same control. As you can see in the attached screencast, the behavior is identical"
        Please note that this behavior is not exhibited in the following circumstances:

        1. A standard WPF Grid hosted inside a floating LayoutPanel could be sized to content
        2. A standard WinForms Grid hosted inside a WindowsFormHost, in a floating LayoutPanel could be sized to content.
        3. The above 2 points is true with a standard window as well.
          I strongly believe this is an issue cropping up from the XtraGrid implementation (or from the sizing logic which we apply). So the solution, I think still will have to be on the XtraGrid side as this is not a standard WPF behavior.
          Thanks,
          -Thomas
        DevExpress Support Team 9 years ago

          Hi Thomas,

          First, let me clarify why this ticket is marked as fixed. After your comment where you posted the following code snippet we have found a general issue in the size-to-content functionality of DXDocking.

          XAML
          <WindowsFormsHost Background="Yellow" x:Name="Host"> <forms:Button Text="Windows Forms control" FlatStyle="Flat"/> </WindowsFormsHost>

          Our developers fixed that issue.
          In the meantime, I must note that setting SizeToContent for a FloatingGroup is insufficient. It is also necessary to set it for each floating panel you want to resize automatically. Please take a look at the attached screenshot where I demonstrated how a panel with the standard Button is resized in this case.

          Regarding the issue with XtraGrid. In order to make sure that it is not related to your custom sizing logic, I have created a clean sample with DXDocking and XtraGrid. The issue occurs there as well.
          As it is not related to the issue we fixed in this thread, I have extracted it to a separate ticket - T334097. I am working on it at the moment and will let you know once I have any results.

          created 9 years ago (modified 9 years ago)

          Hello,
          WinForms' XtraGrid doesn't support such a feature like SizeToContent. WinForms controls are measured based on their parent size and the bounds declared on a form. That's why FloatGroup's SizeToContent property doesn't work, as WindowsFormsHost is measured based on its content. I even recommend you do not use WindowsFormsHost within XtraGrid inside WPF Docking, but use our WPF GridControl instead. The use of WindowsFormsHost within XtraGrid may cause different issues with hosted XtraGrid, which cannot be resolved on our side. So, now you faced only a small part of possible issues. That's why I recommend you use our WPF GridControl instead.

          Thanks,
          Kirill

            Show previous comments (2)

              Also to be clear(and is from the sample posted), we have a floating window(WPF) which has a user control(WPF) having a WindowsFormsHost, hosting an XtraGrid which does't work well with SizetoContent. The SizetoContent works perfectly well when docking is not involved i.e when we have a WPF window with a user control(WPF) as it's content having a WindowsFormhost, hosting an XtraGrid.

                I tried a very simple test to see how WindowsformHost works when windows forms controls are hosted in them in relation with SizeToContent.
                Here is a sample window which has a user control, with a WindowsFormHost & a Windows Form Button inside it. I'm setting the SizeToContent of the window to Width & Height, which works exactly as I want to be. If I set an explicit height on the button Control, the window re sizes to that height.  This is the kind of behavior we have at the moment, but fails to work with Docking.
                <Window x:Class="WpfApplication1.Shell"
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation";
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml";
                       xmlns:wpfApplication1="clr-namespace:WpfApplication1"
                       Title="Shell" SizeToContent="WidthAndHeight">
                 <Grid>
                   <Grid.RowDefinitions>
                     <RowDefinition Height="Auto"></RowDefinition>
                     <RowDefinition Height="*"></RowDefinition>
                   </Grid.RowDefinitions>
                   <StackPanel Orientation="Horizontal" Grid.Row="0">
                     <Button Margin="5" Content="Add"/>
                     <Button Margin="5" Content="Add"/>
                     <Button Margin="5" Content="Add"/>
                     <Button Margin="5" Content="Add"/>
                     <Button Margin="5" Content="Add"/>
                   </StackPanel>
                   <wpfApplication1:MainWindow Grid.Row="1"/>
                 </Grid>
                </Window>
                <UserControl x:Class="WpfApplication1.MainWindow"
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation";
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml";
                       xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms">
                 <WindowsFormsHost Background="Yellow" x:Name="Host">
                   <forms:Button Text="Windows Forms control" FlatStyle="Flat"/>
                 </WindowsFormsHost>
                </UserControl>

                DevExpress Support Team 9 years ago

                  Hi Thomas,
                  I have forwarded this ticket to our developers so they see what might go wrong in our SizeToContent implementation. We will update this thread once we have any results.

                  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.