Loading Layout Loses DataBinding

17 posts, 0 answers
  1. Roberto Montoya
    Roberto Montoya avatar
    3 posts
    Member since:
    Apr 2010

    Posted 24 Jun 2010 Link to this post

    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>

     

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 30 Jun 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gilgen
    Gilgen avatar
    7 posts
    Member since:
    Aug 2010

    Posted 18 Aug 2010 Link to this post

    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...
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 19 Aug 2010 Link to this post

    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
  6. Gilberto
    Gilberto avatar
    65 posts
    Member since:
    Sep 2006

    Posted 13 Sep 2010 Link to this post

    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
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 15 Sep 2010 Link to this post

    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
  8. Gilberto
    Gilberto avatar
    65 posts
    Member since:
    Sep 2006

    Posted 20 Sep 2010 Link to this post

    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.

  9. Gilgen
    Gilgen avatar
    7 posts
    Member since:
    Aug 2010

    Posted 21 Sep 2010 Link to this post

    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.
  10. George
    Admin
    George avatar
    1332 posts

    Posted 23 Sep 2010 Link to this post

    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
  11. Garry Clark
    Garry Clark avatar
    55 posts
    Member since:
    Jan 2005

    Posted 23 Sep 2010 Link to this post

    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>
  12. George
    Admin
    George avatar
    1332 posts

    Posted 27 Sep 2010 Link to this post

    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
  13. Garry Clark
    Garry Clark avatar
    55 posts
    Member since:
    Jan 2005

    Posted 27 Sep 2010 Link to this post

    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!
  14. George
    Admin
    George avatar
    1332 posts

    Posted 30 Sep 2010 Link to this post

    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
  15. jstevenson72
    jstevenson72 avatar
    3 posts
    Member since:
    Aug 2006

    Posted 20 Jan 2015 in reply to George Link to this post

    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






  16. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 22 Jan 2015 Link to this post

    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.

     
  17. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to George Link to this post

    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?
  18. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 11 Mar 2015 Link to this post

    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.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready