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

RadDomainDataSource, MVVM And MEF

6 Answers 99 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Dave Navarro
Top achievements
Rank 2
Dave Navarro asked on 21 Aug 2011, 05:39 AM
Hello,

I have a project that is using MEF (no Prism) along with MVVM. So far so good... I have my large project broken up into several different projects and .xap files that contain user controls. The external .xap files are loaded only when needed... which of course is dependant on the users actions.

But now I'm puzzled. The main application (server app) has the data connections (Entity Data Model, WCF RIA services (started the main project with the MS Business Template)). The external apps know nothing of the main app.... as it should be. They are basically GUI controls needed for a page that the user wishes to load.

My questions are: when I need data... where do I place the RadDomainDataSource? It seems that I need to place it in the external projects ViewModel, but the external project knows nothing of the RIA Services. So, do I then place it into main apps ViewModel? That's the page that is using MEF to load the external .xap file... so, it seems like it should go there. But then, how do I bind it to the incoming View that's being loaded by MEF?

Also, it seems that the external View still needs a ViewModel of it's own so I can bind the controls to properties.

Can someone please give me some clues? Point me to some links? Or, does anyone have an example they can share?

Please let me know and thanks!

~ Dave

6 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Aug 2011, 09:08 AM
Hello Dave Navarro,

RadDomainDataSource is a controls and is designed to be placed on a Silverlight page for easier communication with other controls such as RadGridView, RadDataFilter and RadDataPager. This is described in my introductory blog post.

In case you are doing the MVVM pattern, you should use the inner view called QueryableDomainServiceCollectionView as I have described in this blog post of mine.

As expected, both RadDomainDataSource and its inner view QDSCV<T> will need assembly references to the client-side assemblies of WCF RIA Services, since they are using the DomainContext and EntityQuery<T> classes to communicate with the server.

Since MEF and MVVM are really not Telerik's technologies, I think that the guys on the general Silverlight forums could provide a lot of answers if you ask them.

I hope this helps.

Regards,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dave Navarro
Top achievements
Rank 2
answered on 26 Aug 2011, 12:12 AM
Hello,

Well, so far not so good. It seems that my question / scenario isn't getting the attention / responses that I'd hoped for from Microsoft, MEFedMVVM, MEF.Codeplex.

I posted my question on the Silverlight support forum just today... we'll see what comes from that. Hopefully, someone will have a suggestion or better yet, an answer.

On a good note, I was able to take one of your demo's of the QueryableDomainServiceCollectionView and get it working with MEF. The demo was already using MVVM and so I setup / added MEF to load the ViewModel. It seems to work without too much trouble... actually, it was no trouble at all.

I shall now take what I've learned and attempt to import the external xap file (user control with a gridview) and load it with data from the ViewModel that links the QueryableDomainServiceCollectionView and WCF RIA services.

I'll keep you posted on my experiments.

~ Dave
0
Dave Navarro
Top achievements
Rank 2
answered on 26 Aug 2011, 04:30 AM
Hello once again,

Well, I was able to find the culprit to my current problem but I don't yet have a solution. It seems that when I use the IDeploymentCatalogService something happens that prevents my data from appearing in the gridView. I've remarked out the lines that use the CatalogService and the line to create / import it (shown below).
public partial class DashboardView : Page, IPartImportsSatisfiedNotification
{
public DashboardView()
{
InitializeComponent();
CompositionInitializer.SatisfyImports(this);
//CatalogService.AddXap("bcRMS.RMS.Dashboard.xap"); <-- *** This line here ***
//CatalogService.AddXap("bcRMS.RMS.Navigator.xap"); <-- *** This line here ***
this.radGridView.Items.DescriptorsSynchronizationMode = SynchronizationMode.OneWayToSource;
this.DataContext = DashboardViewModel;
}
[Import]
//public IDeploymentCatalogService CatalogService { get; set; } <-- *** This line here ***
public DashboardViewModel DashboardViewModel { get; set; }
[ImportMany(AllowRecomposition = true)]
public Lazy<UserControl>[] MEFModuleList { get; set; }

When I remove this code my QueryableDomainServiceCollectionView works as expected and fills my gridView with data. When I add this code to import my user control from my external .xap file the gridView is not filled with data.

Please let me know if you have any thoughts on this. I'll keep experimenting with it.

Thanks,

~ Dave
0
Dave Navarro
Top achievements
Rank 2
answered on 26 Aug 2011, 04:44 AM
Hello again,

Well, I won't say I found a bug with QueryableDomainServiceCollectionView but my page / code works when I use the RadDomainDataSource control in the xaml... meaning I get data filling my gridView... while using the IDeploymentCatalogService. Below is the code that works with the IDeploymentCatalogService.
<telerik:RadDomainDataSource Name="customersDomainDataSource"
Width="0"
Height="0"
AutoLoad="True"
QueryName="GetAspnet_Membership">
<telerik:RadDomainDataSource.DomainContext>
<server:AuthDS1 />
</telerik:RadDomainDataSource.DomainContext>
</telerik:RadDomainDataSource>
 
<telerik:RadGridView Name="radGridView"
IsBusy="{Binding IsBusy,
ElementName=customersDomainDataSource}"
ItemsSource="{Binding DataView,
ElementName=customersDomainDataSource}"
telerik:StyleManager.Theme="Windows7" />

When I use the QueryableDomainServiceCollectionView from the codebehind (ViewModel) the datagrid is not filled with data unless I remark out the IDeploymentCatalogService.

So, where does that leave us? Did I find a bug? I guess it's fair to say there is something different about these two functions / controls.

Perhaps someone can take a look under the hood and give me an idea of how I should proceed?

Please let me know and thanks,

~ Dave
0
Rossen Hristov
Telerik team
answered on 29 Aug 2011, 12:07 PM
Hello Dave Navarro,

Please, check this online sample out. It demonstrates how the QueryableDomainServiceCollectionView can be used from inside a view model. Please, not how its AutoLoad property is set to true. Maybe this is the problem.

I have also attached a sample project which shows the QDSCV (two of them in fact) in action.
 
In case you think that you have found a bug in our collection QueryableDomainServiceCollectionView, could you please prepare and send us a runnable sample project that demonstrates this bug?

Regards,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dave Navarro
Top achievements
Rank 2
answered on 29 Aug 2011, 04:09 PM

Hello,

Thanks for the reply. I actually do have the AutoLoad property set to true and of course I'm using the same ViewModel for both scenarios. Both the RadDomainDataSource and QDSCV use the same ViewModel, GridView... everything. The only difference is that when I add the public IDeploymentCatalogService CatalogService { get; set; } property, the QDSCV stops working.

Below is my ViewModel;

namespace bcRMS.ViewModels
{
    [Export(typeof(DashboardViewModel))]
 public class DashboardViewModel : bcViewModelBase
 {
        private readonly QueryableDomainServiceCollectionView<aspnet_Users> view;

        public IEnumerable View
  {
   get
   {
    return this.view;
   }
  }
       
        public bool AutoLoad
        {
            get
            {
                return this.view.AutoLoad;
            }
            set
            {
                if (this.view.AutoLoad != value)
                {
                    this.view.AutoLoad = value;
                    this.OnPropertyChanged("AutoLoad");
                }
            }
        }

  public DashboardViewModel()
  {
            AuthDS1 context = new AuthDS1();
            EntityQuery<aspnet_Users> getAspnet_UsersQuery = context.GetAspnet_UsersQuery();
            this.view = new QueryableDomainServiceCollectionView<aspnet_Users>(context, getAspnet_UsersQuery);
            this.view.PageSize = 20;
            this.view.AutoLoad = true;
  }
 }
}

I will try to create a small project that demonstrates this behavior.

Thanks,

~ Dave

Tags
DomainDataSource
Asked by
Dave Navarro
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Dave Navarro
Top achievements
Rank 2
Share this question
or