Raddocking does not update viewmodel while loading layout

2 posts, 0 answers
  1. Bipin
    Bipin avatar
    13 posts
    Member since:
    May 2013

    Posted 05 Aug 2014 Link to this post

      I am using Raddocking control with Q3 2013 SP released libraries, which supports PanesSource Property. I want to Save/Load layout and content of all opened RadPanes. While loading layout through XamlMainDocker_ElementLoaded event, raddocking control does not update viewmodel binded to PanesSource. Here is my UI, Code behind and viewmodel

    <telerik:RadDocking x:Name="XamlMainDocker" PanesSource="{Binding Path=TrendRadPanes, Mode=TwoWay}" ActivePane="{Binding Path=TrendActivePane,Mode=TwoWay}"
                                    BorderThickness="0" Padding="0" Background="Transparent" Grid.ColumnSpan="2" Margin="-1,0,1,0"
                                    AllowDragReorder="True" AllowUnsafeMode="True" Grid.Column="0" ElementLoaded="XamlMainDocker_ElementLoaded" >

    TrendRadPanes is my ObservableCollection<RadPane>. The application allows user to add radpane at runtime.
    While adding radpan into the TrendsRadpanes collection I am serializing the Radpane in viewmodel as below.

                    RadPane pane1 = new RadPane();
                    pane1.Header = TabName;
                    RadPaneUserControl userControl = new RadPaneUserControl(newTrendTab.TabName);
                    pane1.Content = userControl;
                    RadDocking.SetSerializationTag(pane1, newTrendTab.TabName);

    While saving the layout, I am storing Layout and content of Radpane separately into the database. Here is how I am storing layout as a string.

                MemoryStream stream = new MemoryStream();
                stream.Seek(0, SeekOrigin.Begin);
                StreamReader reader = new StreamReader(stream);

    Load Layout -
                        using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(userSession._layout)))
                            stream.Seek(0, SeekOrigin.Begin);

    As raddocking.SaveLayout does not save content of RadPane, I am using ElementLoaded event to load the content at runtime.

            private void XamlMainDocker_ElementLoaded(object sender, LayoutSerializationEventArgs e)
                RadPane pane = e.AffectedElement as RadPane;
                if (pane != null)
                    AnalyzeTrendsViewModel analyzeVM = LayoutRootAnalyzeTrends.DataContext as AnalyzeTrendsViewModel;
                    pane.Content = analyzeVM.LoadRadPaneUserControl(pane.Header.ToString());
    But it does not update the PanesSource Collection. Please help me to solve my issue. Am I missing something?

  2. Vladi
    Vladi avatar
    743 posts

    Posted 08 Aug 2014 Link to this post

    Hello Bipin,

    Thank you for contacting us.

    You can take a look at our SDK example which demonstrates the use of the PanesSource, DockingPanesFactory and Save/LoadLayout functionality of RadDocking in a more real life scenario. The SDK example could be found in our online repository at GitHub here. You can download the entire repository as a zip file directly from the following link: https://github.com/telerik/xaml-sdk/archive/master.zip. For more details you could also take a look at the blog post related to that example. Hope this is helpful.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft banner
Back to Top