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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:16:46+00:00 2026-06-18T01:16:46+00:00

You cannot bind to a WPF DataGrid’s Columns property, so a workaround is to

  • 0

You cannot bind to a WPF DataGrid's Columns property, so a workaround is to use use an attached property as found in this SO question/answer. My viewmodel exposes an ObservableCollection containing the DataGridColumns, and I bind it to the DataGrid via this attached property.

A background thread is responsible for populating the collection, and I’m using Dispatcher.Invoke to do this, which I thought would avoid threading issues. The background thread itself works fine, but an exception is raised in the above attached property code:

The calling thread cannot access this object because a different thread owns it.

(in the else if that deals with an Add action, specifically the line dataGrid.Columns.Add(column);).

Any idea what might be wrong?

  • 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-18T01:16:47+00:00Added an answer on June 18, 2026 at 1:16 am

    If you are using .NET 4.5, the simplest option is to use BindingOperations.EnableCollectionSynchronization. This allows you to update a collection on a background thread directly, without worrying about synchronization in the binding.

    Otherwise, you need to make sure that all changes to your collection happen on the user interface thread. Using Dispatcher.Invoke should work (provided you get the correct Dispatcher instance), though there are more elegant solutions, such as the binding collections in The Helper Trinity and other projects.

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

Sidebar

Related Questions

Possible Duplicate: Wpf Toolkit. Bind DataGrid Column Header to DynamicResource WPF Error: Cannot find
In a loop which sets up my WPF DataGrid columns, I want to bind
I cannot bind the Visible property of the WPF datagridtextcolumn to a boolean value.
Cannot bind the CollectionViewSource DocProps is a public property public ObservableCollection<DocProp> DocProps1 DataContext is
I want to create an attached property of type ObservableCollection<Notification> and bind it to
This is a 2 part question. 1) Is it possible to bind XDocument to
I bind XML file to WPF TreView using this code: XmlDocument XMLdoc = new
For the life of me I cannot bind the Checked property of a CheckBox
As a follow-up to cannot-bind-to-address-after-socket-program-crashes , I was receiving this error after my program
First off, an apology as I am sure this is question's answer is quite

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.