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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:28:46+00:00 2026-05-29T10:28:46+00:00

I have a window in my application with following resources: <Window.Resources> <ResourceDictionary> <Data:IssueRecords x:Key=DataSource/>

  • 0

I have a window in my application with following resources:

 <Window.Resources>
    <ResourceDictionary>
        <Data:IssueRecords x:Key="DataSource"/>
        <CollectionViewSource x:Key="DataCollection" Source="{StaticResource DataSource}"
                              Filter="CollectionViewSource_Filter">
        </CollectionViewSource>
    </ResourceDictionary>
</Window.Resources>

There is a standard event handler – a method, called CollectionViewSource_Filter and DataGrid, to apply filter to. After my window loads, everything works perfectly, including filters.

For applying filters, I call a ReloadGrid method…

    private void ReloadGrid(object sender, RoutedEventArgs e)
    {
        CollectionViewSource.GetDefaultView(GridData.ItemsSource).Refresh();
    }

But, when user does any action, which makes changes to my database (delete, modify or create new), I need to reload those data sources, so I call…

    private void ReloadDataSources()
    {
        var dataSource = this.FindResource("DataSource") as IStockRecords;
        dataSource.ReloadData();

        var dataCollection = this.FindResource("DataCollection") as CollectionViewSource;
        dataCollection = new CollectionViewSource() { Source = dataSource };
        dataCollection.Filter += new FilterEventHandler(CollectionViewSource_Filter);

        Binding binding = new Binding() { Source = dataCollection };
        BindingOperations.SetBinding(GridData, DataGrid.ItemsSourceProperty, binding);
    }

I think, I do everything, what is needed to read actual data from database and reload the datasources in my window. But when I use any filter, after I call ReloadDataSources(), the filter event is not being used anymore. I debugged a source code and Refresh method doesn’t invoke CollectionViewSource_Filter, even when I set FilterEventHandler…

Am i missing anything?
Thanks, JiKra

  • 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-29T10:28:47+00:00Added an answer on May 29, 2026 at 10:28 am

    OK, there seems to be a problem when I recreated CollectionViewSource object. So, the final version is…

    private void ReloadDataSources()
    {
        var dataSource = this.FindResource("DataSource") as IStockRecords;
        dataSource.ReloadData();
        var dataCollection = this.FindResource("DataCollection") as CollectionViewSource;
        //here I just had to refresh collection's view, not to create a new one
        dataCollection.View.Refresh();
        Binding binding = new Binding() { Source = dataCollection };
        BindingOperations.SetBinding(GridData, DataGrid.ItemsSourceProperty, binding);
    }
    

    Thank you both for your effort…
    JiKra

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

Sidebar

Related Questions

In my MainWindow.xaml, I have the following reference to a ResourceDictionary: <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries>
I have the following WPF application <Window x:Class=Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=clr-namespace:WpfApplication1 Title=Window1 Height=300 Width=300>
I have a C# windows application which does the following: 1) the main form
I have only just started received the following error in my windows forms application
I have the following problem: I implemented a managed mobile application for Windows Mobile
I have the following scenario: - 64bit Windows Server 2008. - 32bit .NET application
I have a window application which uses SP classes to create a site. I
I have developed a window application in VS2005 using C#. I need to integrate
I have developend a window application(Win32 API) in visual C++. I have to add
I have window form in my WPF Application when I open new window from

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.