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 a Custom Control

The beauty of the user control model lies in having the class definition spread across a XAML file and a C# code-behind file. This provides a familiar development experience, just like creating a Page. We can leverage this model for a more sophisticated control, even one that doesn’t derive from UserControl. In this section, we’re going to create such a control called PlayingCard, which represents a playing card to be used in card games.

The tendency for designing a simple user control is to start with the user interface and then later add behavior, as we did with NumericUpDown. For a control that includes better support for things like restyling, it usually makes more sense to start with the behavior. That’s because ...

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