New to Telerik UI for WPF? Download free 30-day trial

Save RadDocking Layout When the Control is Unloaded

Environment

Product Version 2022.3 912
Product RadDocking for WPF

Description

How to save the layout of the RadDocking control when its unloaded.

Solution

  1. Add a new event handler for the Unloaded event of the RadDocking using the EventManager.RegisterClassHandler static method.

    Add a new event handler for the Unloaded event of RadDocking

        EventManager.RegisterClassHandler(typeof(RadDocking), RadDocking.   UnloadedEvent, new RoutedEventHandler(OnUnloaded)); 
    
        EventManager.RegisterClassHandler(GetType(RadDocking), RadDocking.  UnloadedEvent, New RoutedEventHandler(OnUnloaded)) 
    
  2. Implement the save logic in the newly added event handler for the Unloaded event.

    Sample implementation of saving the layout in the newly added handler

        private void OnUnloaded(object sender, RoutedEventArgs e) 
        { 
            using (IsolatedStorageFile storage = IsolatedStorageFile.   GetUserStoreForAssembly()) 
            { 
                using (var isoStream = storage.OpenFile("RadDocking_Layout.xml",    FileMode.Create)) 
                { 
                    this.radDocking.SaveLayout(isoStream); 
                } 
            } 
        } 
    
        Private Sub OnUnloaded(ByVal sender As Object, ByVal e As RoutedEventArgs) 
            Using storage As IsolatedStorageFile = IsolatedStorageFile. GetUserStoreForAssembly() 
                Using isoStream = storage.OpenFile("RadDocking_Layout.xml",     FileMode.Create) 
                    Me.radDocking.SaveLayout(isoStream) 
                End Using 
            End Using 
        End Sub 
    
In this article