Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Saturday, July 7, 2012

How to use the ViewBox in WPF

How to use the ViewBox in WPF

Introduction

The ViewBox is a very useful control in WPF. If does nothing more than scale to fit the content to the available size. It does not resize the content, but it transforms it. This means that also all text sizes and line widths were scaled. Its about the same behavior as if you set the Stretch property on an Image or Path to Uniform.
Although it can be used to fit any type of control, it's often used for 2D graphics, or to fit a scalable part of a user interface into an screen area.
<Button Content="Test" />
 
<Viewbox Stretch="Uniform">
    <Button Content="Test" />
</Viewbox>

No comments:

Post a Comment