Hi,
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" >
<telerik:RadDocking.DockingPanesFactory>
<telerik:DockingPanesFactory/>
</telerik:RadDocking.DockingPanesFactory>
</telerik:RadDocking>
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);
TrendRadPanes.Add(pane1);
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();
docking.SaveLayout(stream);
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);
XamlMainDocker.LoadLayout(stream);
}
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?
Thanks
Bipin
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" >
<telerik:RadDocking.DockingPanesFactory>
<telerik:DockingPanesFactory/>
</telerik:RadDocking.DockingPanesFactory>
</telerik:RadDocking>
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);
TrendRadPanes.Add(pane1);
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();
docking.SaveLayout(stream);
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);
XamlMainDocker.LoadLayout(stream);
}
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?
Thanks
Bipin