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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:00:55+00:00 2026-06-03T09:00:55+00:00

I`m writing a program to view product Information in a Listbox. I have a

  • 0

I`m writing a program to view product Information in a Listbox. I have a text box for searching that automatically filters the list as you typing by ProductName. I have run through my C# code numerous times and I can see the filter actually working but I cannot visually get it to filter or ‘refresh’ on the screen.

C# Code :

private ICollectionView _ProductInfoView;
    public ICollectionView ProductInfoView 
    {
        get{return this._ProductInfoView;}
        set
        {
            this._ProductInfoView=value;
            this.onPropertyChnage("ProductInfoView");
        }
    }

 private void RibbonSetupProduct_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        this.hidePanels();
        new Task(() =>
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                ObservableCollection<ModelProductInformation> productInfoCollection   = new ObservableCollection<ModelProductInformation>(from ProductInfo in new GTS_ERPEntities().ProductInformations select new ModelProductInformation { ProductID = ProductInfo.ProductID,  ProductName = ProductInfo.ProductName , Remark=ProductInfo.Remark});
                this.ProductInfoView = CollectionViewSource.GetDefaultView(productInfoCollection);
                new ProductInfoSearch(ProductInfoView, this.TestTextBox);
            }
                ), DispatcherPriority.DataBind);
        }
        ).Start(); 

        this.PanelProducts.Visibility = Visibility.Visible;
    }

  class ProductInfoSearch
   {
      public ProductInfoSearch(ICollectionView filteredList, TextBox textEdit)
      {
        string filterText = string.Empty;

        filteredList.Filter = delegate(object obj)
        {
            if (String.IsNullOrEmpty(filterText))
            {
                return true;
            }
            ModelProductInformation str = obj as ModelProductInformation;
            if (str.ProductName==null)
            {
                return true;
            }
            if (str.ProductName.ToUpper().Contains(filterText.ToUpper()))
            {
                return true;
            }
            else
            {
                return false;
            }
        };
        textEdit.TextChanged += delegate
        {
            filterText = textEdit.Text;
            filteredList.Refresh();
        };
    }
}

XAML :

<dxe:ListBoxEdit x:Name="ProductInfoList" Margin="1.666,1,8,8" Grid.Column="2" Grid.Row="2" Grid.RowSpan="5"  DisplayMember="ProductName" DataContext="{Binding ProductInfoView, ElementName=window}" ItemsSource="{Binding}"/>

I guess my problem is either Data Binding or inside Task().

  • 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-03T09:00:56+00:00Added an answer on June 3, 2026 at 9:00 am

    i would make the ObservableCollection a private field and just create the instance once and also just create the ICollectionView once. to add new data you can use clear and add on your Collection – try it, it works for me.

     private ObservableCollection<ModelProductInformation> productInfoCollection;
    
     //ctor, just once in the constructor
     this.productInfoCollection =  new ObservableCollection<ModelProductInformation>();
     this.ProductInfoView = CollectionViewSource.GetDefaultView(productInfoCollection);
     new ProductInfoSearch(ProductInfoView, this.TestTextBox);
    
    
    private void RibbonSetupProduct_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        this.hidePanels();
        new Task(() =>
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                var yourData = from ProductInfo in new GTS_ERPEntities().ProductInformations select new ModelProductInformation { ProductID = ProductInfo.ProductID,  ProductName = ProductInfo.ProductName , Remark=ProductInfo.Remark};
                //if you wanna change the collection, simple clear and add(or create AddRange extension)
               this.productInfoCollection.Clear();
    
               foreach(var data in yourData)
               { this.productInfoCollection.Add(data);}
            }
                ), DispatcherPriority.DataBind);
        }
        ).Start(); 
    
        this.PanelProducts.Visibility = Visibility.Visible;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program that uses the Qt Graphics View framework. I have subclassed
Im writing a program that should read input via stdin, so I have the
I have been writing a program that is quite complex compared to what I
I have tried writing program that plays a sound file but have been unsuccessful
I am writing a program that reads the first 20 lines of a text
I'm writing an iPhone program that has a login view controller that allows the
I'm writing a program that sends an email out at a client's specific local
If you are writing a program that is executable from the command line, you
I’m writing an objective-c program that does some calculations based on time and will
I'm writing a plug-in for a program where I have a custom user control

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.