Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8180725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:16:51+00:00 2026-06-07T00:16:51+00:00

I have a service returning an array of type BaseItem. BaseItem has N subtypes.

  • 0

I have a service returning an array of type BaseItem. BaseItem has N subtypes. I’m consuming this service in my WPF application (Prism, MVVM) from a view model. In the constructor of this view model I populate an observable collection of type BaseItem:

public CurrentViewModel(IDataService dataService) 
{ 
    _dataService = dataService

    var baseItems = _dataService.GetAllItems(); // there are many kinds of BaseItems
    _baseItems = new ObservableCollection<BaseItem>(baseItems.ToList()); 
} 

So far so good. In my CurrentView I have an ItemsControl that binds to this collection. In this control I want to render each BaseItem by using another View (and its view model).

Until now, I can’t use DataTemplateSelector because I can’t define each DataTemplate in it, I’m loading N modules (which contain classes which inherit from BaseItem) and PRISM loads them dinamically from an specific folder.

I’m using view Model first approach, what other alternatives do I have to implement the scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:16:53+00:00Added an answer on June 7, 2026 at 12:16 am

    simply export your datatemplate resources as a resourcedictionary from your moduls with the specific subtype as DataType. i do this with MEF and in my main app merge this resourcedictionarys. now all datatemplates/views are known to WPF and the itemscontrol render every subtype viewmodel like you want.

    EDIT:

    modul1.dll

    public class Modul1VM : BaseItemViewModel {} 
    

    ResourceDictionary in modul1.dll exported with MEF

    <DataTemplate DataType="{x:Type local: Modul1VM}">
     <view:Yourmodul1View/>
    </DataTemplate>
    

    modul2.dll

    public class Modul2VM : BaseItemViewModel {} 
    

    ResourceDictionary in modul2.dll exported with MEF

    <DataTemplate DataType="{x:Type local: Modul2VM}">
     <view:Yourmodul2View/>
    </DataTemplate>
    

    your main app

    • merge alle exported Resourcedictionarys

    app.xaml.cs

     [ImportMany("Resourcen", typeof (ResourceDictionary))] 
     private IEnumerable<ResourceDictionary> _importResourcen;
    

    OnStartup

     foreach (var resourceDictionary in _importResourcen)
     {
         this.Resources.MergedDictionaries.Add(resourceDictionary);
     }
    

    your itemscontrol just need the collection of BaseItemViewModels as itemssource

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a service returning an array of type Party. Party has two subtypes,
Let's say I have a WCF service which has a method returning object Person.
I have to consume a .NET hosted web service from a Java application. Interoperability
I have a service(C#) with this method: <s:element name=ObterValoresDosTiposDeProdutoParaWebSite><s:complexType><s:sequence><s:element minOccurs=1 maxOccurs=1 name=FK_TIPO_PRODUTO type=s:int/></s:sequence></s:complexType></s:element> When
Friends, I'm lost here. I have this WCF Rest service returning data in json
I have a web service returning some Json stuff to my iPhone application and
I have a WCF service that is returning a block of xml. One element
I have a WCF service that is returning a lot of data. I want
I have web service urls that were working fine and are now returning the
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.