19 January 2011

XAML - Scaling UI elements with fixed width and height

Sometimes you want the size of a XAML UI element to be dynamic and set it's width and height at the same time. This can be done by:
  • Adding the following using:

    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"

  • Wrapping the UI element in following tag:

    <toolkit:Viewbox Stretch="Uniform">

    </toolkit:Viewbox>

No comments:

Post a Comment