Search code examples
wpfdata-bindingwpf-controlsdatatemplate

WPF pass object from control to controltemplate


I'm trying to pass an object from a control, in this case a RadioButton, to its control template. From there, in the template I want to display the SampleNo string property in the templated control. See the image below, which illustrates it better. Can you guys guide me as to what I'm doing wrong?

Code Sample


Solution

  • well, you can ues datacontext, just like below: enter image description here then you can binding some object to your control's datacontext(If the object has a name attribute ): enter image description here