Decorators in WPF using VB.NET: Part 2

In this article you will learn about the decorators in WPF.
  • 2147

As you learn in my previous article decorators are the branch of container is available in WPF which is use to perform graphical changes on an object. These branch of container is also called the Elements of the container.

In this we explain the next most common category of decorators, that is Viewbox decorator.

Viewbox: Inside the Viewbox the content you place is scaled up or down to fit the bounds of the Viewbox. So, you can say that the Viewbox is a more exotic decorator. The scaling process of Viewbox is much more dramatic than the stretch alignment settings. As you stretch an element, you can change the space that is available to that element. Because of vector drawings uses fixed coordinates this change doesn't have an effect on most vector content. If you want to increase the system DPI setting the scaling that the Viewbox does is similar to the scaling you see in WPF . It changes every onscreen element proportionately, including images, text, lines and shapes, and the borders on common elements such as the buttons.

Example of Viewbox Decorator

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Button Margin="90">
        <Viewbox>
           <Polygon Points="100,25 125,0 200,25 125,50" Fill="Blue" />
        </Viewbox>
    </Button>
</Window>

Output Window

 viewbox.gif

Conclusion

Hope this article helps you to understand the Decorators in WPF.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.