Skip to main content

Tile Class

Represent a simple tile that can display a notification header, can be checked and selected.

Namespace: DevExpress.UI.Xaml.Layout

Assembly: DevExpress.UI.Xaml.Layout.v21.2.dll

NuGet Package: DevExpress.Uwp.Controls

Declaration

public class Tile :
    TileBase

Remarks

The Tile control represents a tile that, in addition to the header (see veHeaderedContentControl.Header), can display the notification header, check mark and selection frame. To specify the notification header, use the TileBase.NotificationHeader property. The notification header can be aligned relative to the tile using the TileBase.HorizontalNotificationHeaderAlignment and TileBase.VerticalNotificationHeaderAlignment properties.

The TileBase.NotificationHeaderStyle, TileBase.NotificationHeaderTemplate and TileBase.NotificationHeaderTemplateSelector properties provides the notification header styling and templating functionality.

The figure below shows a sample Tile control that displays a content, header and notification header.

Tile

If the TileBase.AllowCheck property is set to True, the tile can be checked when right tapped/clicked (or tapped/clicked). The TileBase.CheckMode property specifies the touch gesture used to change the tile check state. To respond to changing the check state, handle the TileBase.CheckedChanged event. The following figure shows the same tile displayed in the unchecked and checked states.

Tile_Unchecked Tile_Checked

If the TileBase.AllowSelection property is set to True, the tile displays the selection frame when the TileBase.Selected property equals True. In this state, the tile is displayed enclosed with a frame, whose color and thickness can be specified by the TileBase.SelectionFrameBrush and TileBase.SelectionFrameThickness properties. See the sample below.

Tile_Selected

The following code snippet shows how to create a simple tile with the slide animation effect.

xmlns:Layout="using:DevExpress.UI.Xaml.Layout"

<Layout:Tile Header="Beverages" AllowCheck="True" Checked="True" Background="Orchid" CheckMode="Tap">
    <StackPanel>
        <StackPanel.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="FontSize" Value="24"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
        </StackPanel.Resources>
        <TextBlock Text="Soft Drinks:"/>
        <Layout:SlideDecorator Orientation="Horizontal">
            <TextBlock Text="Coffee"/>
            <TextBlock Text="Ice Tea"/>
            <TextBlock Text="Juice"/>
        </Layout:SlideDecorator>
    </StackPanel>
</Layout:Tile>

Example

This example demonstrates how to create tiles with various animation effects: flip, swing, slide and mosaic.

<Page
    x:Class="TilesEx.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TilesEx"
    xmlns:Layout="using:DevExpress.UI.Xaml.Layout"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.DataContext>
        <local:ViewModel />
    </Page.DataContext>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Layout:LayoutControl Orientation="Vertical" Grid.Row="1">
            <Layout:LayoutControl.Resources>
                <Style TargetType="Layout:LayoutItem">
                    <Setter Property="HeaderPosition" Value="Top" />
                    <Setter Property="HorizontalContentAlignment" Value="Left" />
                </Style>
            </Layout:LayoutControl.Resources>
            <Layout:LayoutItem Header="Tile BackContent">
                <Layout:Tile Header="Beverages" AllowCheck="True" Checked="True" Background="Orchid" CheckMode="Tap" >
                    <Layout:Tile.BackContentTemplate>
                        <DataTemplate>
                            <Image Source="Assets/Beverages.jpg" Stretch="Fill" />
                        </DataTemplate>
                    </Layout:Tile.BackContentTemplate>
                    <StackPanel>
                        <StackPanel.Resources>
                            <Style TargetType="TextBlock">
                                <Setter Property="FontSize" Value="24"/>
                                <Setter Property="HorizontalAlignment" Value="Center"/>
                            </Style>
                        </StackPanel.Resources>
                        <TextBlock Text="Soft Drinks:"/>
                        <Layout:SlideDecorator ContentChangeInterval="0:0:3">
                            <x:String>Coffee</x:String>
                            <x:String>Ice Tea</x:String>
                            <x:String>Juice</x:String>
                        </Layout:SlideDecorator>
                    </StackPanel>
                </Layout:Tile>
            </Layout:LayoutItem>
            <Layout:LayoutItem Header="Slide Decorator">
                <Layout:Tile Header="Beverages" Background="Orchid" CheckMode="Tap">
                    <StackPanel>
                        <StackPanel.Resources>
                            <Style TargetType="TextBlock">
                                <Setter Property="FontSize" Value="24"/>
                                <Setter Property="HorizontalAlignment" Value="Center"/>
                            </Style>
                        </StackPanel.Resources>
                        <TextBlock Text="Soft Drinks:"/>
                        <Layout:SlideDecorator ContentChangeInterval="0:0:3">
                            <x:String>Coffee</x:String>
                            <x:String>Ice Tea</x:String>
                            <x:String>Juice</x:String>
                        </Layout:SlideDecorator>
                    </StackPanel>
                </Layout:Tile>
            </Layout:LayoutItem>
            <Layout:LayoutItem Header="Swing Decorator">
                <Layout:Tile Header="Zillow" Background="#FF7CA7D1" Size="Wide" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <Layout:SwingDecorator>
                        <Layout:SwingDecorator.ContentTemplate>
                            <DataTemplate>
                                <Image Margin="12" Source="Assets/ZillowLogo.png" Stretch="None"/>
                            </DataTemplate>
                        </Layout:SwingDecorator.ContentTemplate>
                        <Layout:SwingDecorator.TopContentTemplate>
                            <DataTemplate>
                                <TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
                            Your <Bold>Edge</Bold> in <Bold>Real Estate</Bold>
                                </TextBlock>
                            </DataTemplate>
                        </Layout:SwingDecorator.TopContentTemplate>
                    </Layout:SwingDecorator>
                </Layout:Tile>
            </Layout:LayoutItem>
            <Layout:LayoutItem Header="Mosaic Decorator">
                <Layout:Tile Header="Employees" Size="Large" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <Layout:MosaicDecorator ContentSource="{Binding Employees}" ImageColumnCount="3" ImageRowCount="3">
                        <Layout:MosaicDecorator.ContentTemplate>
                            <DataTemplate>
                                <Image Source="{Binding ImageSource}" Stretch="Fill"/>
                            </DataTemplate>
                        </Layout:MosaicDecorator.ContentTemplate>
                    </Layout:MosaicDecorator>
                </Layout:Tile>
            </Layout:LayoutItem>
        </Layout:LayoutControl>
    </Grid>
</Page>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Xml.Serialization;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace TilesEx {
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page {
        public MainPage() {
            this.InitializeComponent();

        }
    }

    [XmlRoot("Employees")]
    public class Employees : List<Employee> {
    }
    [XmlRoot("Employee")]
    public class Employee : INotifyPropertyChanged {
        public int Id { get; set; }
        public int ParentId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string JobTitle { get; set; }
        public string Phone { get; set; }
        public string EmailAddress { get; set; }
        public string AddressLine1 { get; set; }
        public string City { get; set; }
        public string PostalCode { get; set; }
        public string CountryRegionName { get; set; }
        public string GroupName { get; set; }
        public DateTime BirthDate { get; set; }
        public DateTime HireDate { get; set; }
        public string Gender { get; set; }
        public string MaritalStatus { get; set; }
        public string Title { get; set; }
        public byte[] ImageData { get; set; }
        BitmapImage imageSource;
        [XmlIgnore]
        public BitmapImage ImageSource
        {
            get
            {
                if (imageSource == null && ImageData != null) {
                    SetImageSource();
                }
                return imageSource;
            }
        }
        async void SetImageSource() {
            InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
            await stream.WriteAsync(ImageData.AsBuffer());
            stream.Seek(0);

            imageSource = new BitmapImage();
            imageSource.SetSource(stream);
            if (propertyChanged != null)
                propertyChanged(this, new PropertyChangedEventArgs("ImageSource"));
        }

        #region INotifyPropertyChanged Members
        PropertyChangedEventHandler propertyChanged;

        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add { propertyChanged += value; }
            remove { propertyChanged -= value; }
        }
        #endregion
    }
    public class ViewModel : DevExpress.Mvvm.BindableBase {
        public Employees Employees { get { return DataStorage.Employees; } }
    }
    public static class DataStorage {
        static Employees employees;
        public static Employees Employees
        {
            get
            {
                if (employees != null)
                    return employees;
                try {
                    StorageFile file = StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Data/Employees.xml")).AsTask().Result;
                    Stream stream = file.OpenStreamForReadAsync().Result;
                    XmlSerializer serializier = new XmlSerializer(typeof(Employees));
                    employees = serializier.Deserialize(stream) as Employees;
                }
                catch {
                    employees = new Employees();
                    employees.Add(new Employee() {
                        Id = 109,
                        FirstName = "Bruce",
                        LastName = "Cambell",
                        JobTitle = "Chief Executive Officer",
                        Phone = "(417) 166-3268",
                        EmailAddress = "Bruce_Cambell@example.com",
                        AddressLine1 = "4228 S National Ave",
                        City = "Tokyo",
                        PostalCode = "65809",
                        CountryRegionName = "Japan",
                        GroupName = "Executive General and Administration",
                        Gender = "M",
                        Title = "Mr."
                    });
                }
                return employees;
            }
        }
    }
}

Inheritance

Show 12 items
Object
DependencyObject
Windows.UI.Xaml.UIElement
FrameworkElement
Control
Windows.UI.Xaml.Controls.ContentControl
DevExpress.UI.Xaml.Layout.VisualElements.veContentControlBase
DevExpress.UI.Xaml.Layout.VisualElements.veContentControl
See Also