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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:00:49+00:00 2026-06-11T17:00:49+00:00

I have a WPF windows app project, it has a window with two ListBox

  • 0

I have a WPF windows app project, it has a window with two ListBox controls, the question is how can I binding one source to these two contorls?
the source is Like :

class student
{
    public string name{get;set;}
    public int age{get;set;}
}

ObservableCollection<student> m_myGroup;

I want to: ListBox1 binding to m_myGroup if the age > 25
ListBox2 binding to m_myGroup if the age <=25
obviously, both the two ListBox have a

TextBlock Text={binding Path=name}

and I don’t want to use DataTrigger to have the item visibility property Hidden or Show, and I try to use ICollectionView to filter the source, but it will effect the other ListBox!
Does anyone know how to make two filters for each ListBox, and they only binding to one source?

  • 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-11T17:00:51+00:00Added an answer on June 11, 2026 at 5:00 pm
    <Window x:Class="ComboboxStyle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converter="clr-namespace:ComboboxStyle"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <converter:AgeConverter x:Key="ageConv"/>
    </Window.Resources>
    
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListBox Grid.Column="0"  DisplayMemberPath="Name" ItemsSource="{Binding Students, Converter={StaticResource ageConv}, ConverterParameter=agelessthan25}" >
        </ListBox>
        <ListBox  Grid.Column="1" DisplayMemberPath="Name" ItemsSource="{Binding Students, Converter={StaticResource ageConv}, ConverterParameter=agegreaterthan25}" >
        </ListBox>
    </Grid>
    

     public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Students = new ObservableCollection<Student>();
            Students.Add(new Student() { Name = "Aeqwwe", Age = 24 });
            Students.Add(new Student() { Name = "bqwewqeq", Age = 28 });
            Students.Add(new Student() { Name = "cwqeqw", Age = 23 });
            Students.Add(new Student() { Name = "dweqqw", Age = 29 });
            Students.Add(new Student() { Name = "eqweweq", Age = 20 });
            DataContext = this;
        }
        public ObservableCollection<Student> Students { get; set; }
    }
    public class Student
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
    public class AgeConverter : IValueConverter
    {
    
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var items = value as ObservableCollection<Student>;
            if (parameter != null && items != null)
            {
                if (parameter.ToString() == "agelessthan25")
                {
                    return items.Where(i => i.Age < 25).ToList();
                }
                else if (parameter.ToString() == "agegreaterthan25")
                {
                    return items.Where(i => i.Age >= 25).ToList();
                }
            }
            return null;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    I hope this will help

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

Sidebar

Related Questions

I have a WPF Windows application. In one window there is a particular stackpanel
I have WPF app with 2 windows - whats the best way to syncronise
I'm moving my old app from windows forms to WPF and have encountered an
I have a wpf cusotm control derived from combobox System.Windows.Controls.ComboBox the control template is
I am developing a WPF project in vb.net and have multiple windows in it.
I have a simple wpf app which has a button that increments a value
Everyone, I have a WPF app that has a canvas that I have wrapped
I have a WPF user control inside windows form project and I have a
I have been trying to deploy my WPF app, I created a Setup Project
I have a Windows app that I've written in C# 4 and WPF; I've

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.