← Back to articles

WPF MVVM Thread annoyance

I hoped WPF had left WinForms' GUI-thread invoking behind. Then BindingList and DependencyProperty both demanded GUI thread invocation from my ViewModel — which isn't supposed to know the GUI exists. ARGH.

Tedd

In WinForms one of the annoyances is that any GUI operation requires invoking GUI thread to do it. I wrote a blog article on a quick hack to bypass it. I was really hoping this limitation was gone in WPF, but alas…

Lately I’ve been refactoring my IRC client to use a MVVM-like architecture. In MVVM ViewModel should not know of GUI in any way. WPF has a lot of goodies that works well with MVVM. But both BindingList and DependencyProperty requires GUI thread invokation…???

Basically this means that manipulation of lists in ViewModel requires a reference to GUI to pick up GUI-thread?

ARGH! :)

image

Written by Tedd · Oslo, Norway

Follow the journal via RSS