We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to access the element inside the maximized item template in SfTileView?

Platform: UWP |
Control: SfTileView

We can retrieve the element in the MaximizedItemTemplate of UWP SfTileView Item using GetChild() method of VisualTreeHelper class. For instance, we have retrieved the border(“MaximizedItemBorder”) element from the MaximizedTileItem template and change the background color of the element. The following code illustrate the same,

Template for MaximizedTileItem:

     <DataTemplate x:Key="MaximizedTileItemTemplate">
            <Border x:Name="MaximizedItemborder">
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <ColumnDefinition Width="150"/>
                        <ColumnDefinition Width="*"/>
                    <Grid  Grid.ColumnSpan="2" >
                        <TextBlock Text="{Binding}" FontSize="25" 
                                        Margin="20" Foreground="Black"/>
                    <RichTextBlock Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top"  TextWrapping="Wrap"
                                           Margin="20" FontSize="14" FontWeight="Light" Foreground="Black">
                        <Paragraph LineHeight="30">
                                 SfTileView acts as a container that holds a set of tile view items that can contain any content. Items can be maximized, minimized, dragged to reorder and arranged in matrix position to achieve best layout.
                    <StackPanel VerticalAlignment="Center" Margin="20 0" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="2">
                                <Style TargetType="TextBlock">
                                    <Setter Property="FontSize" Value="14"/>
                                    <Setter Property="Foreground" Value="White"/>
                            <Image Source="ms-appx:///Image/Emp_02.png" Margin="5 0" />
                            <TextBlock Text="{Binding Phone}" Grid.Column="1" Margin="5 0" VerticalAlignment="Center"/>



<syncfusion:SfTileView Grid.Row="1" x:Name="sftileview" MaximizedItemTemplate="{StaticResource MaximizedTileItemTemplate}">
            <syncfusion:SfTileViewItem Content="TileItem1" Background="AliceBlue"/>
            <syncfusion:SfTileViewItem Content="TileItem2" Background="Orange"/>
            <syncfusion:SfTileViewItem Content="TileItem3" Background="Blue"/>
            <syncfusion:SfTileViewItem Content="TileItem4" Background="Coral"/>
            <syncfusion:SfTileViewItem Content="TileItem5" Background="DarkCyan"/>


Method to get the required element:

public IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
            if (depObj != null)
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
                    DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
                    if (child != null && child is T)
                        yield return (T)child;
                    foreach (T childOfChild in FindVisualChildren<T>(child))
                        yield return childOfChild;


Method to change the background of the Border element:

private void ChangeBackColor()
            foreach (Border border in FindVisualChildren<Border>(this))
                if (border.Name == "MaximizedItemborder")
                    Random r = new Random();
                    Color randomColor = Color.FromArgb((byte)r.Next(0, 256), (byte)(r.Next(0, 256)), (byte)0, (byte)(r.Next(0, 256)));
                    border.Background = new SolidColorBrush(randomColor);


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/TileViewSample_MaximizedItemTemplate-1710628963.zip


2X faster development

The ultimate UWP UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile