Check ribbonTaskPanes to see if it contains the view model before trying to retrieve the view model.

Check ribbonTaskPanes to see if it contains the view model before trying to retrieve the view model.