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 show Horizontal and vertical scrollbars without overlapping

Platform: WinRT |
Control: SfDataGrid |
.NET Framework: 4.5
Tags: scrollviewer

In WinRT, ScrollBar is overlapped on content by default. You can overcome this behavior by customize the style of Scrollviewer and remove the rowspan and columnspan values respectively as below,

 

 XAML: 

<Style TargetType="ScrollViewer">
                <Setter Property="HorizontalScrollMode" Value="Enabled" />
                <Setter Property="VerticalScrollMode" Value="Enabled" />
                <Setter Property="IsHorizontalRailEnabled" Value="True" />
                <Setter Property="IsVerticalRailEnabled" Value="True" />
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="ZoomMode" Value="Disabled" />
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ScrollViewer">
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid Background="{TemplateBinding Background}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <ScrollContentPresenter x:Name="ScrollContentPresenter" Grid.Row="0" Grid.Column="0"
                                                     Grid.RowSpan="2"
                                                Grid.ColumnSpan="2"
 
                                                ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                Margin="{TemplateBinding Padding}" />
                                    <ScrollBar x:Name="VerticalScrollBar"
                                   Grid.Column="1"
                                           Grid.Row="0"
                                   IsTabStop="False"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   Orientation="Vertical" IndicatorMode="MouseIndicator"
                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                   Value="{TemplateBinding VerticalOffset}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   HorizontalAlignment="Right"/>
                                    <ScrollBar x:Name="HorizontalScrollBar"
                                   IsTabStop="False"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   Orientation="Horizontal" IndicatorMode="MouseIndicator"
                                   Grid.Row="1" Grid.Column="0" 
                                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                   Value="{TemplateBinding HorizontalOffset}"
                                   ViewportSize="{TemplateBinding ViewportWidth}" />
                                    <Border x:Name="ScrollBarSeparator"
                                Grid.Row="1"
                                Grid.Column="1"
                                BorderThickness="0,0,1,1"
                                Background="Gray"
                                BorderBrush="Gray" />
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

 

Note:

You can get the default ScrollViewer style through visual studio designer by right click on the ScrollViewer and navigate through the open context menu to the EditTemplate option. Afterwards just click on the Edit a Copy option.

 

Sample:

WinRTSample

 

 

 

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