Wpf combobox selecteditem not updating

Rated 4.76/5 based on 568 customer reviews

List Box was fine to have a collection of controls. Conclusion The example I describe here is very simple.

The goal was to show the process of creating a dialog thinking in the “MVVM” way.

Of course, we should add real configuration controls such as Check Box, Text Box, etc. Create a View Model class for each View I used to use an abstract base class for all my View Model classes where I implement the INofity Property Changed interface.

I also use a trick from Josh Smith to throw an exception if the property name doesn’t exist when the Property Changed event is raised.

Create sub-configuration dialogs For this example, I created 2 sub-configuration dialogs just for the demo.

I just put a Text Block into a Grid to demonstrate the principles.

Yesterday I found myself needing to periodically sample data for a real-time chart and realized that the “Timer” classes in System. Windows didn’t quite work as expected, raising the following exception: We get this error because when we use the other Timer classes they create a separate thread in the background on which the “Tick”/”Elapsed” events are raised; this is an issue when updating “notify-able” properties which are bound to elements in the UI because the UI must be edited from the thread it was created on (not thread-safe). Lover of high-performance distributed architecture.

This proves itself to be rather inconvenient when using a pattern like MVVM, where we don’t have a handle to an element from the UI in our View Model to synchronize with. As it works out, this timer’s “Tick” event is always raised on the main UI thread.

wpf combobox selecteditem not updating-50

wpf combobox selecteditem not updating-87

wpf combobox selecteditem not updating-23

wpf combobox selecteditem not updating-13

The code-behinds are completely empty and View Model classes are testable !

This demo brings the same type of natural user interaction to desktop WPF (via mouse) that you might find on Surface.

If you are actually developing for Surface, be sure to check out the , I would highly recommend it as a foundation for this article.

Microsoft Surface was first publicly unveiled a couple of years ago.

Since then, I have periodically been asked how one would go about creating a panel that behaves like the application launcher in Surface.

Leave a Reply