DataContext is NULL with DockingPanesFactory

4 posts, 0 answers
  1. Ashley
    Ashley avatar
    5 posts
    Member since:
    Mar 2015

    Posted 30 Mar 2015 Link to this post


    I have dug around but found no answer to this. It seems when my new pane is added to the DocumentHost its DataContext is always null and not inherited. 

    I was thinking there is some way around this with the DockingPanesFactory but I couldn't find it.

    WPF Inspector says that the DataContext is completely fine up until it reaches ContentElement.

    Is there a way to get the ContentElement to inherit the DataContext?

  2. Ashley
    Ashley avatar
    5 posts
    Member since:
    Mar 2015

    Posted 30 Mar 2015 in reply to Ashley Link to this post

    Sorry I should clear up this question slightly:

    I bind my RadDocking panes source:

    PanesSource="{Binding RecordsVMM.RecordViewModels}"

    This is an observable collection, which I want each RadDocumentPane to be bound to each individual item. To achieve this I do the following:

    Declare a custom Pane Factory that Docks with "RecordContainer"


    Then, I use a template selector so based on the TYPE inside PanesSource, I display things differently.

    <telerik:RadPaneGroup x:Name="RecordContainer" DropDownDisplayMode="Visible" ContentTemplateSelector="{StaticResource RecordTemplateSelector}"/>

    Unfortunately, once my template is selected. The DataContext is NULL, so its useless!
  3. DevCraft banner
  4. Ashley
    Ashley avatar
    5 posts
    Member since:
    Mar 2015

    Posted 31 Mar 2015 in reply to Ashley Link to this post

    Spent some time writing a simple app last night which describes this very problem.

    Its not entirely clear in the documentation but hopefully this helps somebody in the future:

    If you are writing a CustomDockingPanes factory its designed so that you can determine what type of RadPane or RadDocumentPane to instantiate _based on your own ViewModel_

    For example, if you use RadDocumentPane in conjunction with a DockingPanesFactory the function CreatePaneForItem WILL NOT GET CALLED because it has already made the assumption that the Pane type is going to be RadDocumentPane - this will then not allow you to pass on the DataContext to it. It just ends up being null.

    In short - if you are using DockingPanesFactory it feels like you should never really have a PaneSource which contains a list of RadDocuments because it removes the point of the Factory (other than deciding where to dock it).

    Hope this makes sense, maybe you can clear this up in your documentation :)
  5. Nasko
    Nasko avatar
    559 posts

    Posted 01 Apr 2015 Link to this post

    Hi Ashley,

    We are glad that you managed to achieve the desired functionality and behavior. Indeed when a collection of RadPanes/RadDocumentPanes is passed to the PanesSource of the Docking control the CreatePaneForItem method from the DockingPanesFactory is not called. The main idea of the method is to create RadPane from an item passed from the collection - if panes are passed to the method its functionality becomes meaningless. We will consider to update our documentation with that information.

    If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top