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

  • Home
  • SEARCH
  • 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 509185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:59:05+00:00 2026-05-13T06:59:05+00:00

I would like to be able to create a DataTemplate to be used when

  • 0

I would like to be able to create a DataTemplate to be used when a collection is passed into a control.

I am building a single control, that when passed an object, or a collection of objects, the view of the user control conforms to the template defined for the object type.

For example, this is a user control I have, that switches views when an object is passed into the .Content property.

<UserControl x:Class="Russound.Windows.UI.UserControls.MAX.OMS_Main_Screen.OMSContextSwitcher"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Entities="clr-namespace:Russound.Components.ReturnAuthorization.Entities;assembly=Russound.Components"
             xmlns:Return_Authorization="clr-namespace:Russound.Windows.UI.UserControls.Return_Authorization" 
             xmlns:CallLog="clr-namespace:Russound.Windows.UI.UserControls.CallLog"
             xmlns:Entities1="clr-namespace:Russound.Components.Membership.Entities;assembly=Russound.Components"
             xmlns:Membership="clr-namespace:Russound.Windows.UI.UserControls.Membership"
             xmlns:Entities2="clr-namespace:Russound.Components.Commerce.MAX.Entities;assembly=Russound.Components"
             xmlns:OMS_Main_Screen="clr-namespace:Russound.Windows.UI.UserControls.MAX.OMS_Main_Screen"
             xmlns:Entities3="clr-namespace:Russound.Components.CallLog.Entities;assembly=Russound.Components"
             MinHeight="600" MinWidth="700">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Russound.Windows;component/UI/RussoundDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>

                <DataTemplate DataType="{x:Type Entities3:Case}" >
                    <CallLog:CaseReadOnlyDisplay DataContext="{Binding}" />
                </DataTemplate>

                <DataTemplate DataType="{x:Type Entities:RAMaster}">
                    <Return_Authorization:RaMasterUi DataContext="{Binding}" />
                </DataTemplate>

                <DataTemplate  DataType="{x:Type Entities1:RussUser}">
                    <Membership:CMCControlWpf DataContext="{Binding}" />
                </DataTemplate >

                <DataTemplate DataType="{x:Type Entities2:MaxCustomer}">
                    <OMS_Main_Screen:MaxCustomerConfigWpf DataContext="{Binding}" />
                </DataTemplate >


        </ResourceDictionary>
    </UserControl.Resources>
</UserControl>

I would like to be able to do something like:

<DataTemplate DataType="{x:Type IEnumerable<MaxCustomer>}">
    <OMS_Main_Screen:MaxCustomerConfigWpf DataContext="{Binding}" />
</DataTemplate >

but I always get a compiler error, so I am at somewhat of a loss.

  • 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-05-13T06:59:05+00:00Added an answer on May 13, 2026 at 6:59 am

    You can create a typed collection and use that type instead of the IEnumerable directly

    public class MyCollection:IEnumerable<MaxCustomer>
    {
       ....
    }
    
     <DataTemplate DataType="{x:Type Entities:MyCollection}">
                <OMS_Main_Screen:MaxCustomerConfigWpf DataContext="{Binding}" />
     </DataTemplate >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 248k
  • Answers 248k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do it using canvas. There was a question… May 13, 2026 at 8:53 am
  • Editorial Team
    Editorial Team added an answer Without using the namespaced versions you are creating an XML… May 13, 2026 at 8:53 am
  • Editorial Team
    Editorial Team added an answer Not exactly what you are asking for, but you check… May 13, 2026 at 8:53 am

Related Questions

I would like to create a simple control that inherits from HeaderedContentControl, and has
In my application, I would like to have DataTemplates such that I can say:
I'm asking myself how to apply MVVM in the following scenario correctly: Let's assume
I am having problems getting at a click event of a button and am
I have a DataGrid whose ItemsSource is bound to a changing Observable Collection. Inside

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.