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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access