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 SimpleCanvas

The first panel we’ll create is a simplified version of Canvas called SimpleCanvas. SimpleCanvas behaves exactly like Canvas, except that it only respects Left and Top attached properties on its children rather than Left, Top, and ZIndex (and Right and Bottom in WPF).

Implementing SimpleCanvas (or any other custom panel) consists of the following four steps:

1. Create a class that derives from Panel.

2. Define any properties that would be useful for customizing layout, potentially including attached properties for the children.

3. Override MeasureOverride and measure each child.

4. Override ArrangeOverride and arrange each child.

Listing 20.1 contains the entire implementation of SimpleCanvas in the context of a Windows ...

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