RibbonWindow: Loaded event strange behavior

2 posts, 1 answers
  1. Megamind
    Megamind avatar
    11 posts
    Member since:
    Jan 2018

    Posted 31 Mar 2019 Link to this post

    According to normal behavior of WPF window, Loaded event occurs when the element is laid out, rendered, and ready for interaction.It is the last event raised in an element initialization sequence. Where as in RadRibbonWindow I have observed that the Loaded event is the first one to be called, even before the Window is shown at all. And when loaded event finished its work then Window appears on screen with all its content loaded. This behavior confuses with the description of Loaded event here  https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement.loaded?redirectedfrom=MSDN&view=netframework-4.7.2 ?

  2. Answer
    Martin Ivanov
    Martin Ivanov avatar
    2403 posts

    Posted 02 Apr 2019 Link to this post

    Hello Megamind,

    Actually, MSDN is a bit inconsistent when it comes to the Loaded event. The article you pointed out (FrameworkElement.Loaded Event), tells that when the Loaded event is fired the control is already rendered. On the other hand the Object Lifetime Events article tells that the Loaded fires just before the rendering. Which is also my observation from my experience with WPF. In addition, during the last a couple of years I've hit few topics over the internet on this topic, and it seems that when the Loaded event is fired, the corresponding control is already measured and arranged, and waits to be rendered.

    Moreover, the RadRibbonWindow derives from the native Window control, which derives from FrameworkElement, where the Loaded events is coming from. In other words, the WPF frameworks is taking care for the Loaded event and there is not much that can be done to alter this.

    If you want to execute something after the window is rendered you can schedule a new action to be execute (in the Loaded event handler) on the next layout pass which probably would be the moment when the window is rendered. 
    private void RadRibbonWindow_Loaded(object sender, RoutedEventArgs e)
        Dispatcher.BeginInvoke(new Action(() => {
            // execute some logic here
    You can try with different DispatcherPriority. This is the second parameter of the BeginInvoke() method.

    I hope this information helps. 

    Martin Ivanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top