WPF C# access combo box on another class running on another thread
Parameters can't be passed when starting a new thread, so what is the best way to access UI element val开发者_开发知识库ues in another class which is running on another thread?
Best Regards!
Parameters can be passed when starting a new thread. See the ParameterizedThreadStart delegate.
Don't access UI elements on another thread, you'll end up in a world of hurt. Instead you should access the View Model (ie. the data) that the item is bound to.
Alternatively, you can use the Dispatcher of the control you're trying to access. But of course, OJ's suggestion of using the ViewModel is better. You are using a ViewModel, right?
You can use Invoke to read values out of your forms.
http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx
精彩评论