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 6579315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:52:59+00:00 2026-05-25T15:52:59+00:00

I have an item controller which I bind to ObservableCollection<User> . I ran into

  • 0

I have an item controller which I bind to ObservableCollection<User>.
I ran into an issue where when there is only one user I would like to show a different ItemTemplate (just the Rating for example – and use default for everything else) and if there are more I would like to let people edit a bit more about them – combo box etc.

I though that probably there is a way of using converter for this, however I’m not sure how I can use converter to pick either one or another. So far I have managed to write a converter to hide/show two separate ItemControls dependable on Count of ObservableCollection<User> property. However, I don’t think this is the best way of solving this problem.

Are there better ways of solving this?

  • 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-25T15:52:59+00:00Added an answer on May 25, 2026 at 3:52 pm

    You need only one ItemsControl with template selection:

     <ItemsControl ItemsSource="{Binding Users}" ItemTemplate="{Binding Users.Count, Converter={StaticResource UserTemplateSelector}"/>
    

    where

        public class UserTemplateSelector : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                int userCount = (int) value;
                if (userCount == 1)
                {
                    return (DataTemplate) Application.Current.Resources["SingleUserTemplate"]; //SingleUserTemplate should be created e.g. in App.xaml
                }
    
                return (DataTemplate)Application.Current.Resources["MultipleUserTemplate"]; //MultipleUserTemplate should be created e.g. in App.xaml
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotSupportedException();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have an item in the ASP.NET CacheObject, which if it
I have a navigation controller, which has the following structure: Category Item Item Detail
Let's assume that we have a controller with some action which could look like:
I have a treeview (winforms) which have different item types on it. I have
I have a list item with buttons in it like so: <mx:List contentBackgroundAlpha=0 baseColor=0x333333
I have a view which might be rendered from a controller or as a
Hey, alright so I have a .plist that looks like; <plist version=1.0> <dict> <key>Item
Hi have a repeater which is inside a gridview. when i bind the data
I have following code which add BackButton on my view's navigation item's tabbar. It
I have two views which will both use the same Controller method: //webServiceController.cs //The

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.