Infragistics® WPF 2016.1
Restrict a XamTile's Size

The xamTileManager™ allows you to restrict a tile's size based on its state. The NormalModeSettings object exposes a TileConstraints property that you can use to restrict the height and width of tiles in normal mode. The MaximizedModeSettings object exposes MaximizedTileConstraints, MinimizedTileConstraints and MinimizedExpandedTileConstraints properties that you can use to restrict the height and width of tiles in maximized, minimized and minimized-expanded mode, respectively.

When you set a NormalModeSettings or MaximizedModeSettings object's properties, the settings apply to all tiles. However, if you want granular control over each tile's constraints, you can set constraints directly on a XamTile object by setting xamTileManager's attached Constraints, ConstraintsMaximized, ConstraintsMinimized and ConstraintsMinimizedExpanded properties. You can use this approach also for adding items that derive from the DependencyObject class.

The size constraints take precedence over all the other size-related settings. Neither xamTileManager nor your end users will be able to resize a tile beyond its constraints. If a xamTileManager feature requires the control to resize a tile, the size constraints will affect the behavior of that feature. For example, if you set the NormalModeSettings object's ShowAllTiles property to True and you set minimum size constraints, xamTileManager may not be able to fit all the tiles into the viewable area since the tiles cannot be resized past the tile constraints.

The following example code demonstrates how to restrict a tile's size using the tile constraints.

In XAML:

<ig:XamTileManager Name="xamTileManager1">
    <ig:XamTileManager.NormalModeSettings>
        <ig:NormalModeSettings>
            <ig:NormalModeSettings.TileConstraints>
                <ig:TileConstraints 
                    PreferredHeight="300" 
                    PreferredWidth="300" 
                    MaxHeight="400" 
                    MaxWidth="400" 
                    MinWidth="200" 
                    MinHeight="200" />
                </ig:NormalModeSettings.TileConstraints>
        </ig:NormalModeSettings>
    </ig:XamTileManager.NormalModeSettings>

    <ig:XamTileManager.MaximizedModeSettings>
        <ig:MaximizedModeSettings>
            
            <ig:MaximizedModeSettings.MinimizedTileConstraints>
                <ig:TileConstraints MaxHeight="100" MinHeight="100" />
            </ig:MaximizedModeSettings.MinimizedTileConstraints>

            <ig:MaximizedModeSettings.MinimizedExpandedTileConstraints>
                <ig:TileConstraints MaxHeight="200" MinHeight="100" />
            </ig:MaximizedModeSettings.MinimizedExpandedTileConstraints>

        </ig:MaximizedModeSettings>
    </ig:XamTileManager.MaximizedModeSettings>

    <!-- TODO: Add tiles here-->
</ig:XamTileManager>

In Visual Basic:

Imports Infragistics.Controls.Layouts
...
Dim normTileConstraints As New TileConstraints With _
    {.PreferredWidth = 300, .PreferredHeight = 300, .MinHeight = 200, .MinWidth = 200, MaxHeight = 400, .MaxWidth = 400}

Dim minTileConstraints As New TileConstraints With _
    {.MaxHeight = 100, .MaxWidth = 100}

Dim minExpTileConstraints As New TileConstraints With _
    {.MaxHeight = 200, .MaxWidth = 100}

If Me.xamTileManager.MaximizedModeSettings Is Nothing Then
    Me.xamTileManager1.MaximizedModeSettings = New MaximizedModeSettings()
End If

If Me.xamTileManager1.NormalModeSettings Is Nothing Then
    Me.xamTileManager1.NormalModeSettings = New NormalModeSettings()
End If

Me.xamTileManager1.NormalModeSettings.TileConstraints = _
    normTileConstraints

Me.xamTileManager1.MaximizedModeSettings.MinimizedTileConstraints = _
    minTileConstraints
Me.xamTileManager1.MaximizedModeSettings.MinimizedExpandedTileConstraints = _
    minExpTileConstraints
...

In C#:

using Infragistics.Controls.Layouts;
...
TileConstraints normTileConstraints = new TileConstraints
{
    PreferredWidth = 300,
    PreferredHeight = 300,
    MinHeight = 200,
    MinWidth = 200,
    MaxHeight = 400,
    MaxWidth = 400
};

TileConstraints minTileConstraints = new TileConstraints
{
    MaxHeight = 100,
    MinHeight = 100
};

TileConstraints minExpTileConstraints = new TileConstraints
{
    MaxHeight = 200,
    MinHeight = 100
};

if (this.xamTileManager1.MaximizedModeSettings == null)
{
    this.xamTileManager1.MaximizedModeSettings =
        new MaximizedModeSettings();
}

if (this.xamTileManager1.NormalModeSettings == null)
{
    this.xamTileManager1.NormalModeSettings =
        new NormalModeSettings();
}

this.xamTileManager1.NormalModeSettings.TileConstraints =
    normTileConstraints;

this.xamTileManager1.MaximizedModeSettings.MinimizedTileConstraints =
    minTileConstraints;
this.xamTileManager1.MaximizedModeSettings.MinimizedExpandedTileConstraints =
    minExpTileConstraints;
...
Related Topics

About Tile Layout

Add Tiles to xamTileManager

Retrieve a Reference to a Tile

Change the State of a Tile

About Saving and Loading Layouts

About Tile Templates

Binding xamTileManager to Data

Explicitly Arrange Tiles

Allow End Users to Close Tiles

Modify Tile Behaviors in Normal Mode

Modify Tile Behaviors in Maximized Mode

About Animations

 

 


Copyright © 2008-2016 Infragistics, Inc. All rights reserved.

E-mail your feedback on this topic.