开发者

WPF contentcontrol loses functionlity after assign null to content

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 as开发者_如何学Pythonsigning 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜