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

  • Home
  • SEARCH
  • 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 850563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:16:59+00:00 2026-05-15T07:16:59+00:00

Can I programatically set the position of a WPF ListBox’s scrollbar? By default, I

  • 0

Can I programatically set the position of a WPF ListBox’s scrollbar? By default, I want it to go in the center.

  • 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-15T07:17:00+00:00Added an answer on May 15, 2026 at 7:17 am

    To move the vertical scroll bar in a ListBox do the following:

    1. Name your list box (x:Name=”myListBox”)
    2. Add Loaded event for the Window (Loaded=”Window_Loaded”)
    3. Implement Loaded event using method: ScrollToVerticalOffset

    Here is a working sample:

    XAML:

    <Window x:Class="ListBoxScrollPosition.Views.MainView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Loaded="Window_Loaded"
      Title="Main Window" Height="100" Width="200">
      <DockPanel>
        <Grid>
          <ListBox x:Name="myListBox">
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
            <ListBoxItem>Zamboni</ListBoxItem>
          </ListBox>
        </Grid>
      </DockPanel>
    </Window>
    

    C#

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
      // Get the border of the listview (first child of a listview)
      Decorator border = VisualTreeHelper.GetChild(myListBox, 0) as Decorator;
      if (border != null)
      {
        // Get scrollviewer
        ScrollViewer scrollViewer = border.Child as ScrollViewer;
        if (scrollViewer != null)
        {
          // center the Scroll Viewer...
          double center = scrollViewer.ScrollableHeight / 2.0;
          scrollViewer.ScrollToVerticalOffset(center);
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in Microsoft Access, is there a way which I can programatically set the Confirm
I want to programatically create an NSTextView. How can I determine the correct frame
I am creating menus in WPF programatically using vb.net. Can someone show me how
How can I programatically set the lock screen image in Windows Phone 7? If
I know I can programatically make the taskbar item for a particular window start
Can I programatically change the quality of a PDF? I have a client that
How can I programatically cause a control's tooltip to show in a Winforms app
How can I programatically get the path to MSBuild from a machine where my
Suppose I create a very simple socket connection, how can one programatically: Find out
How can I retrieve the information shown in the Mac's System Profiler app programatically?

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.