views:

104

answers:

0

I wrote app with multiple views. Viewmodels are assigned to "smartcontentcontrol" which is derived from contentcontrol and overrides contentproperty metadata to handle changed event for that dependency property. I put some effects on that callback for visuals (renderbitmap and so on). Now i have extended my viewmodel so, that uppon assigning object to smartcontentcotrol content property my viewmodel gets reference to smartcontentcontrol object. I implemented this for my viewmodel to be able to close himself.

So - in xaml i have

<DataTemplate DataType="{x:Type viewmodel:MainViewModel}">
   <view:MainView/>
</DataTemplate>

<SmartContentControl Content="{Binding MainView}"/>

in C# i assign some viewmodel class to that property

MainView = new MainViewModel();
  • at this moment everything goes fine and View appears with right datatemplate. Not only that but my smartcontentcontrol triggers as well - i get cool sliding/fading animation - just what i expected - for example - latter in code calling this

    MainView = null;

slides away "old" view with emptines. So far so good! :) now the tricky part which i can not figure out - As soon as i directly assign to

smartcontentcontrol.content = null

Everything breaks down and assigning to MainView no longer changes view or calls onchanged event. It seems like data binding is gone. WHY is that so? How do i workaround this problem?