Intersoft ClientUI Documentation
Viewbox Class
Members  See Also  Send Feedback
Intersoft.Client.UI.Controls Namespace : Viewbox Class






Defines a content decorator that can stretch and scale a single child to fill the available space.

Object Model

Viewbox Class

Syntax

Visual Basic (Declaration) 
<ContentPropertyAttribute("Child")>
Public NotInheritable Class Viewbox 
   Inherits ViewboxInternal
   Implements IControlIFramework, ILicensing 
Visual Basic (Usage)Copy Code
Dim instance As Viewbox
C# 
[ContentPropertyAttribute("Child")]
public sealed class Viewbox : ViewboxInternal, IControlIFramework, ILicensing  
Delphi 
public class Viewbox = class(ViewboxInternal, IControl, IFramework, ILicensing)sealed; 
JScript 
ContentPropertyAttribute("Child")
public sealed class Viewbox extends ViewboxInternal implements IControlIFramework, ILicensing 
Managed Extensions for C++ 
[ContentPropertyAttribute("Child")]
public __gc __sealed class Viewbox : public ViewboxInternal, IControlIFramework, ILicensing  
C++/CLI 
[ContentPropertyAttribute("Child")]
public ref class Viewbox sealed : public ViewboxInternal, IControlIFramework, ILicensing  

Example

The following example demonstrates the difference between each stretch mode.

XAML Copy Code
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
    <Border BorderBrush="Black" BorderThickness="1" Padding="8" Width="150" Height="150" Margin="8">
        <Viewbox Stretch="Uniform">
            <Button Height="40" Width="80" Content="Click Me"></Button>
        </Viewbox>
    </Border>
    <Border BorderBrush="Black" BorderThickness="1" Padding="8" Width="150" Height="150" Margin="8">
        <Viewbox Stretch="Fill">
            <Button Height="40" Width="80" Content="Click Me"></Button>
        </Viewbox>
    </Border>
    <Border BorderBrush="Black" BorderThickness="1" Padding="8" Width="150" Height="150" Margin="8">
        <Viewbox Stretch="UniformToFill">
            <Button Height="40" Width="80" Content="Click Me"></Button>
        </Viewbox>
    </Border>
    <Border BorderBrush="Black" BorderThickness="1" Padding="8" Width="150" Height="150" Margin="8">
        <Viewbox Stretch="None">
            <Button Height="40" Width="80" Content="Click Me"></Button>
        </Viewbox>
    </Border>
</StackPanel>

Remarks

Viewbox is inherited from ISContentControl, which means that it can contain a single object of any type (such as a string, an image, or a panel). For more information about this content model, see Content Model Overview.

Viewbox scales the content to fill 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.

 

Viewbox should inherit from Decorator (which inherits from FrameworkElement), but the closest working base in Silverlight is the ContentControl class. This provides a number of extra APIs not present in WPF that should be avoided (including the Template property which should not be changed from its default value). Viewbox has been sealed to prevent the creation of derived classes that depend on these features not available on its WPF counterpart.

Inheritance Hierarchy

System.Object
   System.Windows.DependencyObject
      System.Windows.UIElement
         System.Windows.FrameworkElement
            System.Windows.Controls.Control
               System.Windows.Controls.ContentControl
                  Intersoft.Client.Framework.ISContentControl
                     Intersoft.Client.UI.Controls.ViewboxInternal
                        Intersoft.Client.UI.Controls.Viewbox

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.