This is a migrated thread and some comments may be shown as answers.

Loading Layout Loses DataBinding

16 Answers 488 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Roberto Montoya
Top achievements
Rank 1
Roberto Montoya asked on 24 Jun 2010, 10:05 PM
When I load my layout all of my binding content is gone.  I had a similar issue with Header content on a RadDocumentPane and the solution was to use a HeaderTemplate.  This did resolve my issue with the header but when I try a similar approach with a ContentTemplate I have no success.

Is there a way to preserve my RadPane content when I load the layout?

I have the following XAML:

 

 

 

<telerik:RadPane x:Name="rpIndexPane" CanUserClose="False" ContextMenuTemplate="{x:Null}" CanDockInDocumentHost="False" Header="Index"

 

 

 

telerik:RadDocking.SerializationTag="IndexPane" DataContext="{Binding}">

 

 

 

 

<ItemsControl DataContext="{Binding}" ItemsSource="{Binding ActiveJob.Patient.CurrentVisit.Sections.Items}" HorizontalContentAlignment="Stretch">

 

 

 

 

<ItemsControl.Template>

 

 

 

 

<ControlTemplate TargetType="ItemsControl">

 

 

 

 

<ScrollViewer VerticalScrollBarVisibility="Auto">

 

 

 

 

<ItemsPresenter/>

 

 

 

 

</ScrollViewer>

 

 

 

 

</ControlTemplate>

 

 

 

 

</ItemsControl.Template>

 

 

 

 

<ItemsControl.ItemTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Button Background="{Binding Color}" Margin="1" Visibility="{Binding Visible, Converter={StaticResource BoolToVisConverter}}">

 

 

 

 

<TextBlock Text="{Binding Name}" Margin="3,5,3,5" HorizontalAlignment="Center"></TextBlock>

 

 

 

 

</Button>

 

 

 

 

</DataTemplate>

 

 

 

 

</ItemsControl.ItemTemplate>

 

 

 

 

</ItemsControl>

 

 

 

 

</telerik:RadPane>

 

16 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 30 Jun 2010, 08:06 AM
Hello Roberto Montoya,

Thank you for contacting us.

Have you reviewed this 2 articles about Load/Save Layout - http://www.telerik.com/help/wpf/raddocking-save-load-the-content-of-the-panes.html and http://www.telerik.com/help/wpf/raddocking-features-save-load-layout.html?
If they does not help you could you please send us a sample project in which this issue is reproduced. In that way we will be able to assist you in a timely manner.

If you have further questions please let us know.

Greetings,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gilgen
Top achievements
Rank 1
answered on 18 Aug 2010, 08:39 AM
Hi,

I've the same problem that you and I saw the 2 articles. The save and load method works fine but the binding doesn't persist.
I tried to implement something that look like the first article. However, they talk about a GetPaneContent method to set the content of the pane but I never see it in any classes (radDocking, radPane, UserControl, Window,...)...

Anyone knows where we can find this famous method because it looks like the lonely solution...
0
Konstantina
Telerik team
answered on 19 Aug 2010, 03:12 PM
Hello Gilgen,

Thank you for your participation in the discussion.

This method is just for an example purposes. You will need to implement it yourself to fit your requirements.

Hope this information helps. If you need further assistance please let us know.

Kind regards,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gilberto
Top achievements
Rank 1
answered on 13 Sep 2010, 10:02 PM
Hello

I,ve tried to follow the sample to save and load layout and content of panes, using the code below.

 private void radDocking_ElementLoaded(object sender, LayoutSerializationEventArgs e)
        {

            var pane = e.AffectedElement as RadPane;
            if (pane != null)
            {
                pane.Content = this.GetPaneContent(e.AffectedElementSerializationTag);
            }
}
But i cannot find the "GetPaneContent", what i am doing wrong?

Thanks
0
Konstantina
Telerik team
answered on 15 Sep 2010, 03:34 PM
Hi Gilberto,

As I mentioned in my previous post the GetPaneContent() method is only for example purposes. You will have to write its implementation, so that it can fit your requirements.

All the best,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gilberto
Top achievements
Rank 1
answered on 20 Sep 2010, 10:06 PM
Thanks Konstantina,

By the way, how can i use the serialization tag in code behind(c#)?

I have tried this way, but does not work.
String titulo = "tst";

RadPane pane = new RadPane();
pane.Name = titulo;

 

Telerik.Windows.Controls.RadDocking.SetSerializationTag(pane, titulo);

Thanks again.

0
Gilgen
Top achievements
Rank 1
answered on 21 Sep 2010, 01:57 PM
Hi,
I spent more than 2 days to find an issue to resolve the content and header lost.
Now my problem is when I have a binding that change the header. The header conserve the value of the binding until the SaveLayout moment, and after that, the binding is lost.
I'm really disappointed because I think there is no real good solution except if you update your RadDocking component.

Do you think that the save/load problem will be resolved soon?

Thanks in advance.
0
George
Telerik team
answered on 23 Sep 2010, 05:02 PM
Hi Gilgen,

Straight to the questions:

  1. Using  RadDocking.SetSerializationTag(radPane, "yourString"); is a proper way to set serialization tag in code behind
  2. As you correctly noticed the Docking control saves the Header text instead of a Binding expression. This implementation is by design. Sorry for any inconvenience caused. You could hook up to the ElementLoaded event of the RadDocking control and to put your binding expression, just like Konstantina suggested you. 

Attached you can find a sample that illustrates this scenario. I hope this helps! I will be glad to assist you further.

Sincerely yours,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Garry Clark
Top achievements
Rank 1
answered on 24 Sep 2010, 02:09 AM
George,
Would I also need something along these lines if I am using RadDocking with Prism? Currently I can save the layout of RadDocking, but when I load the layout Prism can not find the regions associated with the RadPaneGroups. If I comment out the LoadLayout everything works as expected except of course the layout doesn't get loaded. Below is some code that will hopefully clarify what I am talking about.

Any direction you could offer here would be appreciated.

Load Layout Method
private void LoadLayout()
       {
           byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Infrastructure.Properties.Settings.Default.DockLayout);
           MemoryStream ms = new MemoryStream();
           ms.Write(bytes, 0, bytes.Length);
           this.radDock.LoadLayout(ms);
           ms.Close();
       }

RadDocking Xaml
<telerikDocking:RadDocking telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}" 
                                       AllowUnsafeMode="True" diag:PresentationTraceSources.TraceLevel="High" x:Name="radDock">
                <telerikDocking:RadSplitContainer Name="LeftContainer" InitialPosition="DockedLeft" 
                                                  telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}">
                    <telerikDocking:RadPaneGroup x:Name="groupLeftRegion" cal:RegionManager.RegionName="{x:Static i:RegionNames.LeftRegion}" diag:PresentationTraceSources.TraceLevel="High"
                                                 telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}" PropagateItemDataContextToContent="False"/>
                </telerikDocking:RadSplitContainer>
                <telerikDocking:RadSplitContainer Name="BottomContainer" InitialPosition="DockedBottom" 
                                                  telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}">
                    <telerikDocking:RadPaneGroup x:Name="groupBottomRegion" cal:RegionManager.RegionName="{x:Static i:RegionNames.BottomRegion}" diag:PresentationTraceSources.TraceLevel="High"
                                                 telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}" PropagateItemDataContextToContent="False"/>
                </telerikDocking:RadSplitContainer>
                <telerikDocking:RadDocking.DocumentHost>
                    <telerikDocking:RadSplitContainer Name="ContentContainer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  
                                                  telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}">
                        <telerikDocking:RadPaneGroup x:Name="groupContentRegion" cal:RegionManager.RegionName="{x:Static i:RegionNames.ContentRegion}" diag:PresentationTraceSources.TraceLevel="High" 
                                                 telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}" PropagateItemDataContextToContent="False"/>
                    </telerikDocking:RadSplitContainer>
                </telerikDocking:RadDocking.DocumentHost>
            </telerikDocking:RadDocking>
0
George
Telerik team
answered on 27 Sep 2010, 07:41 AM
Hello Garry,

Please refer to our forum thread where you can find interesting notes regarding the usage of Prism and RadDocking. Also, you could find more information in Miroslav Nedyalkov's blog - http://blogs.telerik.com/miroslavnedyalkov/posts/09-08-31/using_the_raddocking_control_with_prism.aspx
 
I hope this helps! Please do not hesitate to contact us if you require any further information. I will be glad to assist you further.


Sincerely yours,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Garry Clark
Top achievements
Rank 1
answered on 27 Sep 2010, 12:55 PM
George,
Thank you for your response, but I have to say I was a little disappointed by the answer. I almost always check the forums before posting and Miroslav and I have had correspondence several times about MVVM Prism and Telerik controls so I had indeed read the blog you suggested. Not that I don't appreciate the links, but in the end I was really looking for a more thoughtful answer to my question.

I guess I will assemble a small sample application and just put a support ticket in. I would however like to suggest that you guys look at doing some more in depth blogs/KB articles on MVVM and Prism, especially when it comes to RadDocking as it seems to be the most finicky control when it comes to this type of implementation.

Thanks again George!
0
George
Telerik team
answered on 30 Sep 2010, 12:07 PM
Hi Garry,

I would suggest you to add a serialization tag to all RadDocking elements as well. (RadPaneGroups, RadSplitContainers, RadPanes). Please, try it and let me know if it helps. 
Also, pay attention to that when you drag and place a group in the docking layout, you actually move only the panes, the group actually stays at the same place where it was (but it has no panes). 

Looking forward to your reply. I will be glad to assist you further.

Greetings,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jstevenson72
Top achievements
Rank 1
answered on 20 Jan 2015, 04:31 PM
Thank you George.  Adding the Serialization Tag to all the other container elements fixed my serialization issue.

The documentation on this seems to imply that what you suggest isn't necessary. It says, "When you load the layout, all the elements that are not marked with SerializationTag property are removed and new components are created instead. That is the reason why you should mark your panes with the SerializationTag attribute."  Which led me to believe that the Panes were the only items needing the attribute. You may want to revise the documentation.

source: http://docs.telerik.com/devtools/silverlight/controls/raddocking/features/save-load-layout.html#load-layout






0
Kalin
Telerik team
answered on 22 Jan 2015, 09:10 AM
Hi Jason,

Thanks for your feedback - we will definitely consider the suggestion.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Nikita
Top achievements
Rank 1
answered on 06 Mar 2015, 12:13 PM
Hi. Sorry, I still don't get it. :(
I am using MVVM and I have a fairly simple global style which adds an icon to pane header, which looks like this:

<DataTemplate x:Key="HeaderTemplate">
    <StackPanel Orientation="Horizontal">
        <Image Margin="0,0,3,0" Source="{Binding Screen.IconSource}" Width="16" Height="16" VerticalAlignment="Center"/>
        <TextBlock Text="{Binding Screen.Title}" x:Name="text" VerticalAlignment="Center"/>
    </StackPanel>
</DataTemplate>
 
<Style TargetType="{x:Type Controls:RadPane}">
    <Setter Property="HeaderTemplate" Value="{StaticResource HeaderTemplate}"/>
    <Setter Property="TitleTemplate" Value="{StaticResource HeaderTemplate}"/>
</Style>

After I load the layout - all the bindings set by this style are broken (at least thats what VS Output window says) and I see empty headers everywhere. How am I supposed to repair this style after the layout is loaded? I could recreate simple bindings in ElementLoaded event, as your example suggests. But what should I do with styles and templates, especially with complex ones?
0
Kalin
Telerik team
answered on 11 Mar 2015, 09:36 AM
Hi Nikita,

We are not aware of such an issue. Can you share some more details about the exact scenario? How do you  create the Panes and how do you set their DataContext? Also what version of the controls are you using? Please provide more sample code reproducing the issue.

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Docking
Asked by
Roberto Montoya
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Gilgen
Top achievements
Rank 1
Gilberto
Top achievements
Rank 1
George
Telerik team
Garry Clark
Top achievements
Rank 1
jstevenson72
Top achievements
Rank 1
Kalin
Telerik team
Nikita
Top achievements
Rank 1
Share this question
or