Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3959028
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:40:46+00:00 2026-05-20T02:40:46+00:00

My ScrollViewer is not working. I’ve created a UserControl to show arrow indicators that

  • 0

My ScrollViewer is not working. I’ve created a UserControl to show arrow indicators that tell the user that the scroll viewer can be scrolled. So now, the content just overflows the ScrollViewer. Here is my XAML:

<UserControl x:Class="QCK.Common.ResourceLibrary.CustomControls.ArrowScrollViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Name="UserControl">
    <UserControl.Resources>

        <Style x:Key="ScrollDownArror" TargetType="{x:Type Border}">
            <Setter Property="Margin" Value="2,0,18,0"/>
            <Setter Property="Visibility" Value="Visible"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=CanScrollDown}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="ScrollUpArror" TargetType="{x:Type Border}">
            <Setter Property="Margin" Value="2,0,18,0"/>
            <Setter Property="Visibility" Value="Visible"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=CanScrollUp}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>
    <Grid>
        <ScrollViewer Name="scrollViewer" VerticalScrollBarVisibility="Visible">
            <ContentPresenter VerticalAlignment="Top"/>
        </ScrollViewer>

        <Border Style="{StaticResource ScrollUpArror}"  DataContext="{Binding ElementName=c_list}"
                                IsHitTestVisible="false"
                                VerticalAlignment="Top">
            <Image Margin="15" Height="20">
                <Image.Source>
                    <DrawingImage>
                        <DrawingImage.Drawing>
                            <GeometryDrawing Brush="DarkGray" Geometry="M  0, 10 L 50, 30 L 100, 10 Z">
                                <GeometryDrawing.Pen>
                                    <Pen Brush="DimGray" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                        </DrawingImage.Drawing>
                    </DrawingImage>
                </Image.Source>
            </Image>
        </Border>

        <Border Style="{StaticResource ScrollDownArror}"  DataContext="{Binding ElementName=c_list}"
                                IsHitTestVisible="false"
                                VerticalAlignment="Bottom">
            <Image Margin="15" Height="20">
                <Image.Source>
                    <DrawingImage>
                        <DrawingImage.Drawing>
                            <GeometryDrawing Brush="DarkGray" Geometry="M  0, 30 L 50, 10 L 100, 30 Z">
                                <GeometryDrawing.Pen>
                                    <Pen Brush="DimGray" />
                                </GeometryDrawing.Pen>
                            </GeometryDrawing>
                        </DrawingImage.Drawing>
                    </DrawingImage>
                </Image.Source>
            </Image>
        </Border>
    </Grid>
</UserControl>

The contents just overflow inside the control not showing a scroll bar or allowing mouse wheel scrolling or anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:40:46+00:00Added an answer on May 20, 2026 at 2:40 am

    I’m not 100% sure how you want this UserControl to work so I might be of target here. The way I understand it, you want to be able to do something like this

    <local:ArrowScrollViewer x:Name="userControl11">
        <TextBox Text="Test" AcceptsReturn="True"/>
    </local:ArrowScrollViewer>
    

    And the TextBox will end up between the Arrow Indicators. In that case I think you’ll need to edit the Template of the UserControl instead. Try it like this

    <UserControl.Resources>
        <Style x:Key="ScrollDownArror" TargetType="{x:Type Border}">
            <Setter Property="Margin" Value="2,0,18,0"/>
            <Setter Property="Visibility" Value="Visible"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=CanScrollDown}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    
        <Style x:Key="ScrollUpArror" TargetType="{x:Type Border}">
            <Setter Property="Margin" Value="2,0,18,0"/>
            <Setter Property="Visibility" Value="Visible"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=CanScrollUp}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <UserControl.Template>
        <ControlTemplate TargetType="{x:Type UserControl}">
            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" Style="{StaticResource ScrollUpArror}"  DataContext="{Binding ElementName=c_list}"
                                        IsHitTestVisible="false"
                                        VerticalAlignment="Top">
                        <Image Margin="15" Height="20">
                            <Image.Source>
                                <DrawingImage>
                                    <DrawingImage.Drawing>
                                        <GeometryDrawing Brush="DarkGray" Geometry="M  0, 10 L 50, 30 L 100, 10 Z">
                                            <GeometryDrawing.Pen>
                                                <Pen Brush="DimGray" />
                                            </GeometryDrawing.Pen>
                                        </GeometryDrawing>
                                    </DrawingImage.Drawing>
                                </DrawingImage>
                            </Image.Source>
                        </Image>
                    </Border>
                    <ScrollViewer Grid.Row="1" Name="scrollViewer" VerticalScrollBarVisibility="Visible">
                        <ContentPresenter Grid.Row="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </ScrollViewer>
                    <Border Grid.Row="2" Style="{StaticResource ScrollDownArror}"  DataContext="{Binding ElementName=c_list}"
                                        IsHitTestVisible="false"
                                        VerticalAlignment="Bottom">
                        <Image Margin="15" Height="20">
                            <Image.Source>
                                <DrawingImage>
                                    <DrawingImage.Drawing>
                                        <GeometryDrawing Brush="DarkGray" Geometry="M  0, 30 L 50, 10 L 100, 30 Z">
                                            <GeometryDrawing.Pen>
                                                <Pen Brush="DimGray" />
                                            </GeometryDrawing.Pen>
                                        </GeometryDrawing>
                                    </DrawingImage.Drawing>
                                </DrawingImage>
                            </Image.Source>
                        </Image>
                    </Border>
                </Grid>                
            </Border>
        </ControlTemplate>
    </UserControl.Template>
    

    Update

    There are several ways which you can access the ScrollViewer in the Template from code behind. Here’s three ways that comes to mind

    • Add an event handler for the Loaded event of the ScrollViewer
    • Use Template.FindName in code behind
    • Traverse the Visual Tree

    Here’s an example using the Loaded event

    <ScrollViewer Loaded="scrollViewer_Loaded"
                  Grid.Row="1"
                  ...>
    

    Code behind

    private ScrollViewer m_scrollViewer;
    private void scrollViewer_Loaded(object sender, RoutedEventArgs e)
    {
        m_scrollViewer = sender as ScrollViewer;
    }
    

    And if you like to use FindName

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        m_scrollViewer = this.Template.FindName("scrollViewer", this) as ScrollViewer;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a usercontrol that has a scrollviewer, then a bunch of child controls
This is not your average My ScrollViewer isn't working question... Assume a window with
The events scrolltoVerticalOffset or the scrolltoHorizontalOffset do not change the values of the scrollviewer.
I have an ScrollViewer that I am trying to do data binding on the
I have a StackPanel inside of a ScrollViewer. I have a slider that does
I want to access a scrollviewer from another thread. Please tell me how to
I have a Silverlight 4 out-of-browser application with a ScrollViewer that has several RichTextBoxes
Is it possible to create a Trigger that is triggered based on a ScrollViewer
i am currently working on a sample for a lib that i wrote,designed to
I am following Apple's ScrollSuite example, however pinch to zoom is not working. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.