c# - MVVM: Bind ContentControl to CheckBox -


i have contentcontrol want bind it's content property ischecked property of checkbox. using mvvm, idea thought of doing this:

<contentcontrol contenttemplate="{binding currenttemplate}"/> <checkbox ischecked="{binding isnewcustumor}"/> 

and in view model listen isnewcustumor property change , assign corresponding datatemplate currenttemplate property, think involve using views in view model not mvvm. idea write converter class, don't know how should implement it.

so can help?

as far understand want switch template based on value of property isnewcustomer. 1 way achieve this, using style trigger. advantage is, purely xaml , easy read:

<contentcontrol>     <contentcontrol.style>         <style targettype="contentcontrol>             <style.triggers>                 <datatrigger binding="{binding isnewcustomer}" value="true">                     <setter property="contenttemplate" value="set template new customers here">                 </datatrigger>             </style.triggers>          <setter property="contenttemplate" value="set template not new customers here">         </style>     <contentcontrol.style> <contentcontrol> 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -