Using the ComboBox SelectedItem property in WPF / MVVM

An implementation of using the WPF Combo Box using MVVM patterns. The intention is to get a ComboBox control’s SelectedItem property to bind to an instance of a selected object, so that when the SelectedItem is changed, all other entities that are bound to it are also updated. See this StackOverflow discussion for background information: …

Continue reading ‘Using the ComboBox SelectedItem property in WPF / MVVM’ »

Controlling DocumentViewer methods and properties using MVVM

In this post I demonstrate how the methods of a DocumentViewer class may be invoked via MVVM / WPF in order to modify the way an embedded PowerPoint presentation is displayed. Step 1: Create a new WPF application Step 2: Create the Main Window view Just a simple view to house the DocumentViewer control and …

Continue reading ‘Controlling DocumentViewer methods and properties using MVVM’ »

How to bind the WindowState property of a window in WPF using MVVM

Step 1: Create a new WPF project Step 2: Create the ViewModel classes Add the ViewModel classes that are used to do the bindings with the User Interface components MainWindowViewModel.cs This includes the WindowState property and setting this state to maximized upon construction: ViewModelBase.cs Step 3: Update the MainWindow.xaml – add the DataContent So that …

Continue reading ‘How to bind the WindowState property of a window in WPF using MVVM’ »

How to use Interaction Triggers to handle user-initiated events in WPF / MVVM

Example scenario: User clicks the mouse in a WPF application – how do we ‘listen’ to that event in order to trigger and handle an event in the main code? A possible solution is to use in WPF MVVM. See this post to learn how to do this using MvvmLight: https://www.technical-recipes.com/2017/handling-mouse-events-in-wpf-mvvm-using-mvvmlight-event-triggers/ Here is an example …

Continue reading ‘How to use Interaction Triggers to handle user-initiated events in WPF / MVVM’ »