You misunderstood
Canvas
and
ViewBox
. Your bug is binding of the
Canvas
side.
Think logically:
ViewBox
already adjusts the size to its client area. The size of the
Canvas
should simply be fixed; it should be related to the sized of your graphic element, like your ellipse elements.
For example, choose the canvas size of, say, 500 x 500, to fit its children. In a
ViewBox
, you should consider the units as a relative units, to express relative positions and sizes of the children relative to the
Canvas
.
So, the example of the fix will be: replace you view box element with
<Viewbox Stretch="UniformToFill">
and your canvas with
<Canvas Background="AntiqueWhite" Width="500" Height="500">
Some useful reading:
KISS principle — Wikipedia, the free encyclopedia[
^].
—SA