Updating custom userControls in TabbedMdiHost

Docking/MDI for WPF Forum

Posted 10 years ago by Sasha
Version: 13.2.0591
Avatar

Hi,

I have TabbedMdiHost element and I dinamically load documentWindows like tabs. Each documentWindow has custom number of userControls from database. The problem is, that layout on the unactive tabs is updated only when I selecet a documentWindow. So when I select first documentWindow, I wait untill layout will be updated, then when I select second document window, I wait again and so on for each tab. It happens when I select documentWindow for the first time. When I select for the second time the same window, it's working fine. Is there a way to update layout of all documentWindows at once?

Thank you 

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

The docking windows by default are like a regular WPF TabControl/TabItem setup.  Basically only the selected tab's content is ever put in the visual tree.  That's probably why you don't see them updating their layout until their related tab is selected.

You might need to try calling methods like UpdateLayout() on each of your UserControls taht aren't selected, if you want them to be updated earlier on.  Perhaps you could trigger whatever code you need from a DockSite.WindowCreated event handler instead.  See if that helps.


Actipro Software Support

Posted 10 years ago by Sasha
Avatar

Hi,

this is my TabbedMdiHost with : 

<docking:SplitContainer> 
    <docking:TabbedMdiHost Content="{Binding MdiContainer, UpdateSourceTrigger=PropertyChanged}" 
                                                   IsCloseButtonOnTab="False"/>
</docking:SplitContainer> 

  I have loaded event where I create tabs, userControls and in the end I'm trying to update layout :

foreach (var item in MdiContainer.Items)
{
    var temp = item as DocumentWindow;
    if (temp != null && !temp.IsSelected)
        temp.UpdateLayout();
}

 but still layout is updated only when I select documentWindow. Also I was trying to update layout while bringingIntoView first documentWindow and SplitContainer, on DockSite.WindowOpening and DockSite.WindowActivated and result was the same. You suggested to updateLayout earlier, but there is a little issue - I'm creating userControls asynchronously, so updateLayout earlier does not make sence. May be there is possibility to update all layouts when selecting only one documentWindow? 

[Modified 10 years ago]

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

One problem (not related) that I see with your XAML is that you appear to be building your own TabbedMdiContainer and doing bindings on that.  It is always a bad thing to attach to specific container instances (whether they are TabbedMdiContainer, ToolWindowContainer, etc.) because they are all transient and get dynamically created/destroyed.  If you want to do an MVVM setup for your documents, then please follow the instructions in our documentation on MVVM and look at the related MVVM samples since those show you how to do it properly, and without tying to a specific container instance.

As for your main problem, the DocumentWindow is represented in the UI by its tab.  So anytime you call UpdateLayout on it, you really are only affecting the tab and not its UI.  You need to be trying to call UpdateLayout on the DocumentWindow's Content instead, which should be the UserControl.  You can try that after your UserControls are created.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.