For example, if the Viewbox is twice as large as the Grid??™s desired size, the
Viewbox scales all its content by a factor of 2.
nNote Usually, you??™ll only want to use the Viewbox for vector graphics, not ordinary elements and controls.
By default, the Viewbox performs proportional scaling that preserves the aspect ratio of
its contents. That means that even if the shape of the button changes, the shape inside won??™t.
(Instead, the Viewbox uses the largest scaling factor that fits inside the available space.) However,
you can change this behavior using the Viewbox.Stretch property. By default, it??™s set to
Uniform. Change it to Fill, and the content inside the Viewbox is stretched in both directions
to fit the available space exactly, even if it mangles your original drawing.
You can also get more control with the StretchDirection property. By default, this property
is set to Both, but you can use UpOnly to create content that can grow but won??™t shrink
beyond its original size and DownOnly to create content that can shrink but not grow.
nTip If you need more control, such as the ability to set a maximum upper bound and lower bound for the
size of your content, consider limiting the size of the Viewbox (or its container) using properties such as
MaxHeight, MinHeight, MaxWidth, and MinWidth.
Pages:
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282