O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required