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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:43:27+00:00 2026-06-05T02:43:27+00:00

My Databinding works fine in my DataGrid, but when I try to get the

  • 0

My Databinding works fine in my DataGrid, but when I try to get the collectionview from my CollectionViewSource, it is null, and my filter in DataGrid does not work. Here is the code:

<Window.Resources>
    <CollectionViewSource x:Key="jobItemViewSource" d:DesignSource="{d:DesignInstance my:JobItem, CreateList=True}"/>
</Window.Resources>

<Grid Visibility="Visible" ShowGridLines="False" UseLayoutRounding="True" DataContext="{StaticResource jobItemViewSource}">

<DataGrid Grid.Row="4" Grid.ColumnSpan="6" LoadingRow="jobItemDataGrid_LoadingRow" ItemsSource="{Binding}" Name="jobItemDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" AutoGenerateColumns="False" Grid.RowSpan="2">
                    <DataGrid.Columns>
                        <DataGridTextColumn x:Name="workOrderNoColumn" Binding="{Binding Path=WorkOrderNo}" Header="Work Order No." Width="75" />
                        <DataGridTextColumn x:Name="assigneeColumn" Binding="{Binding Path=PrimaryAssignee}" Header="Assignee" Width="80" />
                        <DataGridTextColumn x:Name="dateReceivedColumn" Binding="{Binding Path=DateReceived}" Header="Date Received" Width="90" />
                        <DataGridTextColumn x:Name="dueDateColumn" Binding="{Binding Path=DueDate}" Header="Due Date" Width="90" />
                        <DataGridTextColumn x:Name="statusColumn" Binding="{Binding Path=Status}" Header="Status" Width="70" />
                    </DataGrid.Columns>

                </DataGrid>
<CheckBox Content="Show Active Jobs" Name="actJobsCheckBox" Grid.Column="1" Grid.ColumnSpan="2"  Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="AddFiltering" Unchecked="RemoveFiltering"/>
                <CheckBox Content="Show Completed Jobs" Name="compJobsCheckBox" Grid.Column="3" Grid.ColumnSpan="3"  Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="AddFiltering" Unchecked="RemoveFiltering"/>

</Grid>

In my code behind, I have the following:

public partial class AdminView : Window
{
    ObservableCollection <JobItem> JobItemList = new ObservableCollection<JobItem>();
    CollectionViewSource jobItemViewSource = new CollectionViewSource();
    ICollectionView view; 
    MainWindow parent;
    Employee currEmployee;
    GroupFilter filterList = new GroupFilter();

    public AdminView(MainWindow parent, Employee currEmployee)
    {
        this.parent = parent;
        this.currEmployee = currEmployee;
        InitializeComponent();
        jobItemDataGrid.DataContext = JobItemList;
        jobItemViewSource = (CollectionViewSource)(this.Resources[jobItemViewSource]);
        view = CollectionViewSource.GetDefaultView(jobItemDataGrid);


    }

private void AddFiltering(object sender, RoutedEventArgs args)
    {
        CheckBox check = sender as CheckBox;
        Predicate<object> active = new Predicate<object>(ContainsActive);
        Predicate<object> completed = new Predicate<object>(ContainsComp);

        switch (check.Name)
        {
            case "actJobsCheckBox":
                filterList.AddFilter(active);
                if( view != null)
                    view.Filter = filterList.Filter;
                break;
            case "compJobsCheckBox":
                filterList.AddFilter(completed);
                if (view != null)
                    view.Filter = filterList.Filter;
                break;
        }


    }

    private void RemoveFiltering(object sender, RoutedEventArgs args)
    {
        CheckBox check = sender as CheckBox;
        Predicate<object> active = new Predicate<object>(ContainsActive);
        Predicate<object> completed = new Predicate<object>(ContainsComp);

        switch (check.Name)
        {
            case "actJobsCheckBox":
                filterList.RemoveFilter(active);
                break;
            case "compJobsCheckBox":
                filterList.RemoveFilter(completed);
                break;
        }

    }

    public bool ContainsActive(object de)
    {
        JobItem item = de as JobItem;

        return (item.Status != "Completed");
    }

    public bool ContainsComp(object de)
    {
        JobItem item = de as JobItem;

        return (item.Status == "Completed");
    }
  • 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-05T02:43:30+00:00Added an answer on June 5, 2026 at 2:43 am

    I have actually figured out my own answer, I just needed to refresh my view and it works.

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

Sidebar

Related Questions

I'm using ASPxGridView and updating with data from DataTable which, works fine. But when
I'm having one hell of a time trying to get my databinding to work
I got a textbox and use databinding to an object. This works fine, until
I have an ObservableCollection bound to a DataGrid and everything works fine. I want
I define a headertemplate into a wpf groupbox and the databinding doesn't work. I
When doing databinding does one have to implement INotifyPropertyChanged on the datacontext in WPF?
I'm trying to do some WPF databinding, but I'm a little hung up at
I have a DataGridView that uses databinding, with manually created columns, and this works
Why databinding TwoWay don't work on the text property of a combobox in .net
I'll try to put this as clearly as I can, but I'm all too

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.