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开发者_如何学Go.
Is there any such controls already available that I can use.
OK, here is a brief overview of what you will need to do ...
- Firstly, you will need to change the
ControlTemplate
for the existingRadioButton
control. There are lots of tutorials available that describe this,, for example this one. - Replace the standard template with some suitable markup for your illustration above. Perhaps a two column
Grid
? - Within each
Grid
cell add a Rectangle, one behind Option1, and the other behind Option2 - Use the VisualStateManager to change the
Fill
property of eachRectangle
based on the controls currentVisualState
. i.e. whenPressed
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.
精彩评论