How to open the window popup inside a C1DockTabControl

Posted by: rambabu on 9 June 2023, 8:02 am EST

    • Post Options:
    • Link

    Posted 9 June 2023, 8:02 am EST

    Hello,

    I have a requirement to open the Window popup inside the C1DockTabControl, but when I open the window as a modal popup, it blocks all the docking controls float/hide.

    I need the window to open inside the C1DockTabcontrol, is there any way to implement this?

    Can you please let me know if this is possible?

    https://www.awesomescreenshot.com/video/18199364

    DockingExplorer.zip

    Thanks & Regards

  • Posted 12 June 2023, 6:33 pm EST

    Hi Rambabu,

    C1Window’s ShowModal method displays a window over a greyed-out layer preventing the user from interacting with anything else until the window is closed.

    it blocks all the docking controls float/hide.

    As per our understanding you don’t want that the other functionality of C1DockControl to get blocked when new window is opened. If this is the case, we recommend you display the window using Show() method.

    I need the window to open inside the C1DockTabcontrol, is there any way to implement this?

    In order to achieve the required behavior, you can modify the code inside button’s click event as shown in the following code:

    [code]var tabItem = btn.Parent as C1DockTabItem;

    var tabControl = tabItem.Parent as C1DockTabControl;

    // Get the position of the control relative to the window

    Point positionRelativeToWindow = tabControl.TransformToAncestor(Application.Current.MainWindow)

    .Transform(new Point(0, 0));

                // The positionRelativeToWindow variable now contains the control's position relative to the window
                double x = positionRelativeToWindow.X;
                double y = positionRelativeToWindow.Y;
                C1Window window = new C1Window();
                window.Width = 300;
                window.Height = 300;
                window.Left = (tabControl.ActualWidth > window.Width) ? (x + (tabControl.ActualWidth - window.Width)/2 ): x;
                window.Top = (tabControl.ActualHeight > window.Height) ? (y + (tabControl.ActualHeight - window.Height) / 2) : y;
    
    
                window.Content = "Hello World!";
                window.Show();[/code]
    

    Kindly refer to the attached sample for full implementation. See DockingExplorer_Mod.zip

    Please let us know if you need any further help.

    Thanks & Regards,

    Aastha

  • Posted 6 July 2023, 9:01 am EST

    Is there any way to set the parent of the window to the tab control. so that the resizing of the window shouldn’t exceed the height and width of the tab control?

  • Posted 8 July 2023, 6:33 pm EST

    Hi Rambabu,

    We are sorry to inform you that there is no way that you can set the window as the child of the TabControl.

    In case you want to control the resizing of window such that it does not exceed the dimensions of the parent dock tab control, you can handle window’s SizeChanged event as shown below:

    private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
            {
                var window = sender as C1Window;
                string[] dimParent = window.Tag.ToString().Split(':');
                double XParent = 0, YParent = 0;
                double widthParent=0, heightParent=0;            
                if (Double.TryParse(dimParent[0], out XParent) && Double.TryParse(dimParent[1], out YParent))
                {
                    heightParent = double.Parse(dimParent[2]);
                    widthParent = double.Parse(dimParent[3]);
                }
                if (window.Left < XParent)
                {
                    window.Left = XParent;
                    window.Width = e.PreviousSize.Width;
                }
                if (window.Top < YParent)
                {
                    window.Top = YParent;
                    window.Height = e.PreviousSize.Height;
                }
                if ((window.Left + e.NewSize.Width) > (XParent + widthParent))
                {
                    window.Width = e.PreviousSize.Width;
                }
                if ((window.Top + e.NewSize.Height) > (YParent + heightParent))
                {
                    window.Height = e.PreviousSize.Height;
                }
            }
    

    We have stored the dimensions of the parent dock control in the Window’s Tag property. The SizeChanged event handler ensures that the window remains within the bounds of its parent by adjusting its position and size if necessary. Please note that this is a workaround and may have certain limitations.

    We have attached a sample application for your reference. DockingExplorer_Mod.zip

    Kindly let us know if you need any further help regarding this.

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels