views:

64

answers:

1

Hello,

I am switching my UserControls via DataTemplate. When I leave the UserControl/DataTemplate View I need to ask wether the user wants to save or not because else all data will be lost like graphical location points x,y of a user drag/dropped Rectangle on a canvas.

How can I hook into the datatemplate change and bring up my own save dialog?

A: 

So you're binding a ContentControl's Content property to a property in your viewmodel?

The best place to implement this workflow would be where you normally set this viewmodel's property. Doing this in the viewmodel, rather than trying to hook into events in the View layer means you have more control and testability.

Rob Fonseca-Ensor
yes I am doing in xaml: <ContentControl Content="{Binding VM}"VM is the specific ViewModel set via datatemplate in the xaml code to the specific usercontrol.Hm... but I should rather implement this workflow where I normally UNset THIS specific ViewModel... When I switch I only know the new ViewModel but not the old one to put my custom code there. You understand?
msfanboy