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