RadDocking and MEF (how to inject RadDocking)

7 posts, 0 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 14 Jun 2011 Link to this post

    Hello,

    I’m using MEF to load XAP modules into a parent application. The container in the parent application is a RadPaneGroup control as shown in the following code snippet:


          <!-- Main Content Panel of the parent application -->

          <TelerikDocking:RadDocking.DocumentHost>

            <TelerikDocking:RadSplitContainer Width="Auto">

              <TelerikDocking:RadPaneGroup x:Name="MEFContent">

              </TelerikDocking:RadPaneGroup>

            </TelerikDocking:RadSplitContainer>

          </TelerikDocking:RadDocking.DocumentHost>

     

    All goes well as long as my loaded XAP modules consists of a RadPane control as its own container. There’s no problem using MEF.


    I would like to have your advice on the following scenario: what if the XAP to load contains a RadDocking control itself? I mean, I can’t load a RadDocking control in the parent’s RadPaneGroup. The XAP module I’m trying to load consists of a RadDocking control containing SplitContainers and RadPanes itself. I can’t seem to figure out how to inject this into my parent container (which is a RadPaneGroup control).


    I’m using Silverlight Q1 2011 SP1 controls.

     

    Thanks for your advice.

  2. George
    Admin
    George avatar
    1332 posts

    Posted 20 Jun 2011 Link to this post

    Hi Peter, 


    Thank you for contacting us.

    Currently there are two ways of injecting views into the RadDocking control 
    1. inject the RadPanes into a RadPaneGroup (the RadPane is defined as a view in a separate xap)
    2. inject a UserControl into a RadPane (in this case, you need to define all the RadPanes in the xaml at initial start up)

    We don't support placing a RadDocking into another RadDocking control because of some restrictions by design. You could set RadDocking.AllowUnsafeMode property to True, but this could lead to an unexpected behavior and we don't support it.


    All the best,
    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
  3. DevCraft banner
  4. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 09 Aug 2011 Link to this post

    Hello,

    I'm doing something similar with a project and tried to apply your suggestion (#1) but ran into a minor problem. I setup a user control / View(separate XAP) and attempted to inject that into the RadPaneGroup but it errors out.

    Should I set the RadPanes (in my new view) in a <Grid> or some parent container first?

    Please let me know and thanks!

    ~ Dave
  5. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 09 Aug 2011 Link to this post

    Hello Dave,

    I managed to get it done the following way:

    PARENT CONTAINER (separate View) :

    // some other code.

          <telerikDocking:RadDocking.DocumentHost>
            <telerikDocking:RadSplitContainer Width="Auto"
                                              Visibility="Visible">
              <telerikDocking:RadPaneGroup x:Name="MainContent">
              </telerikDocking:RadPaneGroup>
            </telerikDocking:RadSplitContainer>
          </telerikDocking:RadDocking.DocumentHost>

        </telerik:RadDocking>


    CHILD CONTAINER (separate View) :

    <telerik:RadPane
      Tag="AudioRadPane"
      // namespaces, ...
      Header="todo AudioParent">
      <Grid>

        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />      
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>
         
        <telerik:RadSplitContainer Grid.Row="1">

          <!-- Current Track -->
          <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="30, 300">
            <telerik:RadPane Header="todo current track">
            </telerik:RadPane>
          </telerik:RadPaneGroup>

          <!-- Current Playlist -->
          <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="20, 300">
            <telerik:RadPane Header="todo current playlist">
            </telerik:RadPane>
          </telerik:RadPaneGroup>

          <!-- Recently Played Tracks & Indicators -->
          <telerik:RadSplitContainer Orientation="Vertical"
                                       telerik:ProportionalStackPanel.RelativeSize="20, 300">
            <telerik:RadPaneGroup>
              <telerik:RadPane Header="todo recent tracks">
              </telerik:RadPane>
            </telerik:RadPaneGroup>
            <telerik:RadPaneGroup>
              <telerik:RadPane Header="todo indicators">
              </telerik:RadPane>
            </telerik:RadPaneGroup>
          </telerik:RadSplitContainer>

          <!-- Volume Indicators -->
          <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="10, 300">
            <telerik:RadPane Header="todo volume">
            </telerik:RadPane>
          </telerik:RadPaneGroup>

        </telerik:RadSplitContainer>

        <telerik:RadSplitContainer Grid.Row="2">

          <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="40, 100">
            <Playlist:PlaylistView></Playlist:PlaylistView>
          </telerik:RadPaneGroup>
          <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="60, 100">
            <telerik:RadPane Header="todo tracks" />
          </telerik:RadPaneGroup>

        </telerik:RadSplitContainer>

      </Grid>

    PlaylistView itself is a separate view:

    <telerik:RadPane
      x:Class="PlaylistView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    // rest of the code


    I hope this helps!

    Peter.
  6. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 09 Aug 2011 Link to this post

    Hello,

    Thank you for the quick response. I'll give your suggestion a try...

    I have another quick question specific to MEF. Does it matter what type of object I export? Should it be a "class" or should it be an "interface"?

    Here (below) is how I've setup my .cs file to export;
    **********************************************************

    using System.ComponentModel.Composition;
    using System.Windows.Controls;

    namespace bcRMS.Samples.Incident
    {
        [PartCreationPolicy(CreationPolicy.NonShared)]
        [Export(typeof(UserControl))]
        public partial class IncidentView : UserControl
        {
            public IncidentView()
            {
                InitializeComponent();
            }
        }
    }
    **********************************************************

    Please let me know if you see anything I should change.

    Many thanks in advance,

    ~ Dave

  7. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 10 Aug 2011 Link to this post

    Dave,

    I'm far from being a MEF specialist. Aside from that, I don't see anything wrong with your code. I'm usually not exporting a generic Usercontrol object, but rather a strong type ("IncidentView" in your case). The code importing your object will need, at some point, "IncidentView" I suppose?

    I started learning MEF using this blog posts: http://blogs.msdn.com/b/gblock/archive/2009/11/30/building-the-hello-mef-dashboard-in-silverlight-4-part-i.aspx. But, I have to admit, in a "real life application" things can become quite difficult. I'm facing a steep learning curve myself.


    Succes on your project,

    Peter.
  8. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 10 Aug 2011 Link to this post

    Hello,

    Thanks once again for your feedback. The link you sent was one that I also reviewed - good stuff. I actually got the samples working but since my application was started with the business template I thought I should look for a different example. I finally found one that was based on the navigation template... which is pretty close, so I switched over.

    Anyway, I was able to get my user control to load into the main page via MEF however the results were not as I expected. It seems that some of the telerik controls render differently when injected into a application so I'm going to research my new problem and perhaps start a new thread that refers specifically to the sizing of the user controls and the "height, width" properties being set to "infinity".

    Just in case, if anyone wants to see my updated code I can certainly post it here. It's nothing revolutionary but it does seem to work for the moment.

    Thanks again!

    ~ Dave
Back to Top
DevCraft banner