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

RadDocking and MEF (how to inject RadDocking)

6 Answers 124 Views
Docking
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 14 Jun 2011, 03:45 PM

6 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 20 Jun 2011, 08:20 AM
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
0
Dave Navarro
Top achievements
Rank 2
answered on 09 Aug 2011, 05:50 PM
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
0
HDC
Top achievements
Rank 1
answered on 09 Aug 2011, 06:34 PM
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.
0
Dave Navarro
Top achievements
Rank 2
answered on 09 Aug 2011, 08:11 PM

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

0
HDC
Top achievements
Rank 1
answered on 10 Aug 2011, 08:17 AM
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.
0
Dave Navarro
Top achievements
Rank 2
answered on 10 Aug 2011, 05:25 PM
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
Tags
Docking
Asked by
HDC
Top achievements
Rank 1
Answers by
George
Telerik team
Dave Navarro
Top achievements
Rank 2
HDC
Top achievements
Rank 1
Share this question
or