Creating the Behavior

The PlayingCard control should have a notion of a face, which can be set to one of 52 possible values. It should be clickable. It could also have a notion of being selected, for which each click toggles its state between selected and unselected. (This behavior could be provided by an items control containing each PlayingCard, but for the purposes of this example we’ll make it a built-in part of the control.)

Before implementing the control, it helps to think about the similarities between the control and any of the built-in controls. That way, you can choose a better base class than just UserControl and leverage as much built-in support as possible.

For PlayingCard, the notion of a face is sort of like the Foreground property ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.