About initialization of document window

Docking/MDI for WPF Forum

Posted 1 year ago by Yuki
Version: 23.1.3
Avatar

Hello,

I would like to get resource information in Loaded event of document window.

However, I cannot get it sometimes...

Since it is difficult to explain here, I will send simple sample project later.

Would you please check it?

private void OnDocumentWindowLoaded(object sender, RoutedEventArgs e)
{
    if (sender is DocumentWindow document)
    {
        // Sometimes null is returned.
        var resource = document.TryFindResource("LabelStyle");
    }
}

Comments (1)

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The DockSite hierarchy is filled with multiple levels of templated controls and since you are loading the default layout in the Window's contructor, it could be that some of the templates along the way haven't been fully applied yet at that point.  My suggestion would be to change your line to this instead:

var resource = document.DockSite?.TryFindResource("LabelStyle");

That way you use the root DockSite as the anchor for where to look and skip over all those other intermediate layers.  That did return a resource in my test with your sample.


Actipro Software Support

The latest build of this product (v24.1.3) 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.