Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Scrollbar at Left side for Grid
posted

Back in June 2009 rameshnkl posted a question "Is there any possible to move the scrollbar to Left side? (content should be normal)."

Various thigs were suggested, culminating in a reference to this link: http://msdn.microsoft.com/en-us/library/cc278065(VS.95).aspx

After this the discussion stopped.

I have tried the approach shown in the link and its does not work. (The XamDataGrid gets scrollbars but they don't work and the grid no longer loads all the data (or if it does, it doesn't display it).

Is there a way of moving the scrollbar to the left and having it work properly? Any chance of an example?

Parents
  • 27093
    posted

    Hello Nigel,

     

    I have been looking into this issue and even thought I didn’t find the discussion you referred to I managed to use the suggestion. I cannot say what is the approach you have tried based on this link, but I altered what appears to be the original template of the ScrollViewer like so:

     

    <Style TargetType="ScrollViewer"  >

        <Setter Property="HorizontalContentAlignment" Value="Left" />

        <Setter Property="VerticalContentAlignment" Value="Top" />

        <Setter Property="VerticalScrollBarVisibility" Value="Visible" />

        <Setter Property="Padding" Value="4"/>

        <Setter Property="BorderThickness" Value="1"/>

        <!--<Setter Property="BorderBrush">

            <Setter.Value>

                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                    <GradientStop Color="#FFA3AEB9" Offset="0"/>

                    <GradientStop Color="#FF8399A9" Offset="0.375"/>

                    <GradientStop Color="#FF718597" Offset="0.375"/>

                    <GradientStop Color="#FF617584" Offset="1"/>

                </LinearGradientBrush>

            </Setter.Value>

        </Setter>-->

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="ScrollViewer">

                    <Border CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">

                        <Grid Background="{TemplateBinding Background}">

                            <Grid.RowDefinitions>

                                <RowDefinition Height="*"/>

                                <RowDefinition Height="Auto"/>

                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>

                                <ColumnDefinition Width="Auto"/>

                                <ColumnDefinition Width="*"/>

                                               

                            </Grid.ColumnDefinitions>

     

                            <ScrollContentPresenter x:Name="ScrollContentPresenter" Grid.Column="1"

                                        Cursor="{TemplateBinding Cursor}"

                                        Margin="{TemplateBinding Padding}"

                                        ContentTemplate="{TemplateBinding ContentTemplate}"/>

     

                            <Rectangle Grid.Column="0" Grid.Row="1" Fill="#FFE9EEF4"/>

     

                            <ScrollBar x:Name="VerticalScrollBar" Width="18"

                            IsTabStop="False"

                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"

                            Grid.Column="0" Grid.Row="0" Orientation="Vertical"

                            ViewportSize="{TemplateBinding ViewportHeight}"

                            Maximum="{TemplateBinding ScrollableHeight}"

                            Minimum="0"

                            Value="{TemplateBinding VerticalOffset}"

                            Margin="0,-1,-1,-1"/>

     

                            <ScrollBar x:Name="HorizontalScrollBar" Height="18"

                            IsTabStop="False"

                            Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"

                            Grid.Column="1" Grid.Row="1" Orientation="Horizontal"

                            ViewportSize="{TemplateBinding ViewportWidth}"

                            Maximum="{TemplateBinding ScrollableWidth}"

                            Minimum="0"

                            Value="{TemplateBinding HorizontalOffset}"

                            Margin="-1,0,-1,-1"/>

     

                        </Grid>

                    </Border>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

     

     

    All I did was move the ContentPresenter, Rectangle and two ScrollBars inside the container Grid (setting their Grid.Row and Grid.Column properties) and switch the Grid’s ColumnDefinitions Widths. Everything seems to work ok and I cannot think of a way for this to prevent the XamDataGrid from loading its data since the grid is simply set as the ContentPresenter.

     

    Please test this out by placing it in the XamDataGrid’s Reseources and let me know if there is something bothering you or if I can assist you any further on the matter.

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support

     

Reply Children