Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight: Custom Radio button

Tags:

c#

silverlight

I am trying to develop a custom radio button that looks like a two-option button control that looks somewhat as shown below with toggling of highlighted state. Not sure where to start.

enter image description here

Is there any such controls already available that I can use.

like image 712
softwarematter Avatar asked Aug 09 '26 08:08

softwarematter


1 Answers

OK, here is a brief overview of what you will need to do ...

  1. Firstly, you will need to change the ControlTemplate for the existing RadioButton control. There are lots of tutorials available that describe this,, for example this one.
  2. Replace the standard template with some suitable markup for your illustration above. Perhaps a two column Grid?
  3. Within each Grid cell add a Rectangle, one behind Option1, and the other behind Option2
  4. Use the VisualStateManager to change the Fill property of each Rectangle based on the controls current VisualState. i.e. when Pressed toggle the background colours.

The steps above should help you achieve your goal. Please read the linked web pages and the Silverlight documentation. If you are still struggling after that,, come back and ask another question.

like image 167
ColinE Avatar answered Aug 10 '26 21:08

ColinE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!