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 customize the border around the item of SfTileView?

Platform: UWP |
Control: SfTileView

When we hover the TileViewItem, rectangle will be displayed around the TileViewItem. We can customize the appearance of this rectangle by customizing the style of the TileViewItem. For instance, we have changed the color of the rectangle in below code example,

 

Mainwindow.xaml:

       <syncfusion:SfTileView x:Name="tileview">
            <syncfusion:SfTileViewItem Content="TileItem1" />
            <syncfusion:SfTileViewItem Content="TileItem2" />
            <syncfusion:SfTileViewItem Content="TileItem3"/>
            <syncfusion:SfTileViewItem Content="TileItem4"/>
            <syncfusion:SfTileViewItem Content="TileItem5"/>
        </syncfusion:SfTileView>

 

Style of TileViewItem:

        
        <SolidColorBrush x:Key="SelectedItemBorderColor" Color="Red" />
        
        <Style TargetType="syncfusion:SfTileViewItem">
            <Setter Property="Margin" Value="5" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="syncfusion:SfTileViewItem">
                        <Grid>
 
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PointerOverRect">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0.3" 
                                                        Storyboard.TargetProperty="Opacity" 
                                                        Storyboard.TargetName="PART_Host"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
 
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DragDropStates">
                                    <VisualState x:Name="ScaleIn">
                                        <Storyboard >
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_Host">
                                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_Preview">
                                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0.8"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <Storyboard >
                                                <Storyboard x:Name="Storyboard4">
                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="PART_PreviewHost">
                                                        <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.1">
                                                            <EasingDoubleKeyFrame.EasingFunction>
                                                                <ExponentialEase Exponent="6"/>
                                                            </EasingDoubleKeyFrame.EasingFunction>
                                                        </EasingDoubleKeyFrame>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="PART_PreviewHost">
                                                        <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.1">
                                                            <EasingDoubleKeyFrame.EasingFunction>
                                                                <ExponentialEase Exponent="6"/>
                                                            </EasingDoubleKeyFrame.EasingFunction>
                                                        </EasingDoubleKeyFrame>
                                                    </DoubleAnimationUsingKeyFrames>
 
 
                                                </Storyboard>
 
                                            </Storyboard>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
 
                            <Grid x:Name="PART_Host">
                                <Grid.RenderTransform>
                                    <CompositeTransform />
                                </Grid.RenderTransform>
                                <Rectangle Margin="-3" Fill="Transparent" Stroke="{StaticResource SelectedItemBorderColor}" StrokeThickness="3" Opacity="0"
                                   x:Name="PointerOverRect"/>
                                <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}" />
                                </Border>
 
                            </Grid>
                            <Popup x:Name="PART_Preview" IsHitTestVisible="False">
                                <Grid x:Name="PART_PreviewHost" Opacity="0.8" Background="{TemplateBinding Background}">
                                    <Grid.RenderTransform>
                                        <CompositeTransform/>
                                    </Grid.RenderTransform>
                                    <Border Background="{TemplateBinding Background}">
                                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" />
                                    </Border>
                                </Grid>
                            </Popup>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

 

Output:

 

TileView customization in UWP

 

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/TileViewSample-1477846858.zip

2X faster development

The ultimate UWP UI toolkit to boost your development speed.
ADD COMMENT
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