wpf - wp8 Binding CheckBox to CustomMessageBox via DataTemplate -


i make own control. inside want define data template use in custom message box. in code open dialog can't set start value check box inside it.

please me - how correctly bind cbvoiceattchecked variable custommessagebox via datatemplate named voicetemplate

xaml:

<usercontrol x:class="myproj.rdpcontrol" ... >  <usercontrol.resources>     <datatemplate x:key="voicetemplate" >         <stackpanel margin="32,0,0,0">             <checkbox x:name="cbvoiceatt" content="..." ischecked="{binding cbvoiceattchecked}"/>             ... /*other checkboxes*/         </stackpanel>     </datatemplate> </usercontrol.resources>  <grid x:name="layoutroot">     ... here main control - works </grid> 

in code

public partial class rdpcontrol : usercontrol {     public rdpcontrol()     {         initializecomponent();         //this.datacontext = this;     }      public bool cbvoiceattchecked { get; set; }  ....      private void voicebutton_tap(object sender, system.windows.input.gestureeventargs e)     {         cbvoiceattchecked = true; // value binding temlate!!!         custommessagebox messagebox = new custommessagebox()         {             caption = "...",             message = "...",             contenttemplate = (datatemplate)(this.resources["voicetemplate"]), // use template xaml             datacontext = this, // want use cbvoiceattchecked variable bind dialog             leftbuttoncontent = "yes",             rightbuttoncontent = "no"         };         ...         messagebox.show();      } 

you need either change cbvoiceattchecked property dependencyproperty, or implement inotifypropertychanged interface in rdpcontrol class.

you can find out more inotifypropertychanged interface in inotifypropertychanged interface on msdn , dependencypropertys in dependencyproperty class , dependency properties overview pages on msdn.

of course, depends on doing contenttemplate object inside rdpcontrol class. did not show that, cannot confirm making above change fix problem.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -