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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:12:20+00:00 2026-06-04T14:12:20+00:00

I am building a WPF application that takes in rows of data, and outputs

  • 0

I am building a WPF application that takes in rows of data, and outputs them into different tabs in the GUI based on the data contained in the row. However, the tabs aren’t known until runtime, so I need to dynamically build an unknown number of tabs with collection views with different filters off of my main ObservableCollection.

The problem I have been running in to is that using ListCollectionViews I need a predicate filter but I do not know of a way to have a dynamic predicate based on a local variable? I tried variable capturing, but that just changes all of my filters each time a new tab is added.

//class variables
string currTab;
public ObservableCollection<MyData> myCollection = new ObservableCollection<myData>();
private void DataAdd(object sender, RoutedEventArgs e)
{
   currTab = inputData.ToString();
   ListCollectionView c = new ListCollectionView(myCollection);
   c.Filter = new Predicate<object>(MyFilter);
}
public bool MyFilter(object foo)
{
   if (foo).ToString() != currTab)
      return false;
   else
      return true;
}

I also tried using lambda expressions and with ICollectionView, but the collection doesn’t update with new values, so I just see empty tabs.

CollectionView c = new CollectionViewSource { Source = myCollection.Where(z => z.ToString() == tabName) }.View;

Is there a way to make either of these approaches work? Or a better way to do 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-06-04T14:12:22+00:00Added an answer on June 4, 2026 at 2:12 pm

    it turns out I just needed to use a local variable for the predicate

    var b = currTab
    c.Filter = (foo) =>{return foo.ToString() == b;}; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a WPF application that calls web services and displays the data
I'm building a WPF application that will be run on laptop computers mounted in
I'm building an application using WPF that will be a designer of sorts, meaning,
Building a stand alone WPF application that uses a MSSQL backend. I would like
I am building an application that has a WCF service that a WPF and
I'm building a MEF-based plugin-centric WPF application and I'm facing an issue with GetExports,
I'm currently tasked with building a spreadsheet-like GUI for a WPF application and I've
I'm building a WPF application that is designed to act as a notification toolbar
I'm building a WPF application and this WPF application is having a toolbar-like panel
I'm building WPF client application. I'm following MVC pattern. The project solution has many

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.