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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:56:10+00:00 2026-06-18T07:56:10+00:00

I am creating a control that displays a summary of data. On this page

  • 0

I am creating a control that displays a summary of data. On this page I am binding a control to an ObservableColection that contains many items. I created a CollectionView that sorts the items by time but in this control I only want to show the top 3 items. I tried creating a converter to accomplish this but all ways I try to filter the list return a “new” list and the control is no longer updated when a new item is added to the master ObservableCollection.

Is there a clean way to accomplish this? I will have to do something similar for several of my collections so I would like to make something generic.

  • 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-18T07:56:11+00:00Added an answer on June 18, 2026 at 7:56 am

    If you’re using the ViewModel pattern, the clean way is to have another ObservableCollection with the top N items. That way the binding is direct and you can change 3 to whatever N you want only by changing your model.

    public class MyViewModel
    {
        private ObservableCollection<string> myList;
    
        public ObservableCollection<string> MyList 
        { 
            get { return myList; }
            set { return myList; }
        }
    
        public Collection<string> MyListTop3 
        {
            get { return new Collection<string>(MyList.Take(3).ToList()); }
        }
    
        public MyViewModel() 
        {
            myList = new ObservableCollection<string>();
    
            myList.CollectionChanged += (sender, args) =>
            { 
                RaisePropertyChanged("MyListTop3");
            }; 
        } 
    }
    

    If you want to that care of it only through XAML (no the cleaneast way):

    <ListBox>
    
        <ListBox.Resources>
            <ContentPresenter x:Key="value0" Content="{Binding MyList[0]}"/>
            <ContentPresenter x:Key="value1" Content="{Binding MyList[1]}"/>
            <ContentPresenter x:Key="value2" Content="{Binding MyList[2]}"/>
        </ListBox.Resources>
    
        <ListBoxItem Content="{DynamicResource value0}"/>
        <ListBoxItem Content="{DynamicResource value1}"/>
        <ListBoxItem Content="{DynamicResource value2}"/>
    
    </ListBox>
    

    This example shows a ListBox but you can use it on any other control.

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

Sidebar

Related Questions

How can I go about creating a control that has items in item that
I am creating a control that displays a hex value (For example FFAA-CA10-56D7) .
I'm creating a custom control in wxWidgets that displays a menu as part of
I am creating a user control that contains a panel as well as 4
Greetings! I'm creating a User Control that will display data in a GridView control.
Given that you're creating a User Control in WPF that will be displayed on
I'm creating an air traffic control system. I have a class called plane that
I am creating a custom control. I want the template for this control to
I am dynamically creating a table that contains a textbox in each cell. The
I'm writing a monitoring system that displays real-time sensor data. The sensors are arranged

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.