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 4545826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:52:03+00:00 2026-05-21T15:52:03+00:00

Both are quite general terms but I’m curious to know when these height will

  • 0

Both are quite general terms but I’m curious to know when these height will be different apart from the case we’re using Virtualization?

One more question:
I read on MSDN:

If CanContentScroll is true, the values of the ExtentHeight, ScrollableHeight, ViewportHeight, and VerticalOffset properties are number of items. If CanContentScroll is false, the values of these properties are Device Independent Pixels.

However I’m facing an issue with ViewPort Height: I’ve 2 listbox in application:
1. Which have Virtualization Enabled and CanContentScroll = True.
2. Which have no virtualization and CanContentScroll = True.

In ListBox 1 while drag-drop Viewport Height comes to 4/5 (Number of elements currently visible). However in ListBox 2 i get Viewport Height equal to Actual Height of Listbox.

Why this difference?

Few more findings:
1. Scrollable Height is number of items not visible in scrollviewer
2. Viewport Height is number of items visible in scrollviewer.
Thus Viewport Height + ScrollableHeight = Extent Height

Can someone please explain what’s the difference between two listboxes? I need ViewPort hieght in case of Listbox 1

  • 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-21T15:52:04+00:00Added an answer on May 21, 2026 at 3:52 pm

    Finally This was the root cause:

    Quoting from https://stackoverflow.com/a/3062692/3195477:

    You are encountering the differences between physical scrolling and
    logical scrolling.

    As you have discovered, each has its tradeoffs.

    Physical scrolling

    Physical scrolling (CanContentScroll=false) just goes by pixels, so:

    The viewport always represents exactly the same portion of your scroll
    extent, giving you a smooth scrolling experience, and but

    The entire contents of the DataGrid must have all templates fully
    applied and be measured and arranged to determine the size of the
    scrollbar, leading to long delays during loading and high RAM usage,
    and It doesn’t really scroll items so it doesn’t understand
    ScrollIntoView very well Logical scrolling

    Logical scrolling (CanContentScroll=true) calculates its scroll viewport and extent by items instead of pixels, so:

    The viewport may show a different number of items at different times,
    meaning the number of items in the viewport as compared to the number
    of items in the extent varies, causing the scrollbar length to change,
    and

    Scrolling moves from one item to the next and never in between,
    leading to "jerky" scrolling

    but

    As long as you’re using VirtualizingStackPanel under the hood, it only
    needs to apply templates and measure and arrange the items that are
    actually visible at the moment, and

    ScrollIntoView is much simpler since it just needs to get the right
    item index into view

    Choosing between them

    These are the only two kinds of scrolling provided by WPF. You must
    choose between them based on the above tradeoffs. Generally logical
    scrolling is best for medium to large datasets, and physical scrolling
    is best for small ones.

    A trick to speed loading during physical scrolling is to make the
    physical scrolling better is to wrap your items in a custom Decorator
    that has a fixed size and sets its child’s Visibility to Hidden when
    it is not visible. This prevents the ApplyTemplate, Measure and
    Arrange from occuring on the descendant controls of that item until
    you’re ready for it to happen.

    A trick to make physical scrolling’s ScrollIntoView more reliable is
    to call it twice: Once immediately and once in a dispatcher callback
    of DispatcherPriority.ApplicationIdle.

    Making logical scroll scrollbar more stable

    If all your items are the same height, the number of items visible in
    the viewport at any time will stay the same, causing the scroll thumb
    size to stay the same (because the ratio with total number if items
    doesn’t change).

    It is also possible to modify the behavior of the ScrollBar itself so
    the thumb is always calculated to be a fixed size. To do this without
    any hacky code-behind:

    • Subclass Track to replace the calculation of Thumb position and size in MeasureOverride with your own

    • Change the ScrollBar template used for the logical-scrolling ScrollBar to use your subclassed Track instead of the regular
      one

    • Change the ScrollViewer template to explicitly set your custom ScrollBar template on the logical-scrolling ScrollBar
      (instead of using the default template)

    • Change the ListBox template to use explicitly set your custom ScrollViewer template on the ScrollViewer it creates

    This means copying a lot of template code fom the built-in WPF
    templates, so it is not a very elegant solution. But the alternative
    to this is to use hacky code-behind to wait until all the templates
    are expanded, then find the ScrollBar and just replace the ScrollBar
    template with the one that uses your custom Track. This code saves two
    large templates (ListBox, ScrollViewer) at the cost of some very
    tricky code.

    Using a different Panel would be a much larger amount of work:
    VirtualizingStackPanel is the only Panel that virtualizes, and only it
    and StackPanel to logical scrolling. Since you are taking advantage of
    VirtualizingStackPanel’s virtualization abilities you would have to
    re-implement all of these plus all IScrollInfo info function plus your
    regular Panel functions. I could do something like that but I would
    allocate several, perhaps many, days to get it right. I recommend you
    not try it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I quite confuse with both. First, both might seen the same. May I know
I've been doing quite a bit of debugging of managed applications lately using both
Both ideas sound very similar to me, but there might be subtle differences or
Both of these appservers are at least in part OSGI based. One (Glassfish) is
This question is about a general technique in SQL, that I can't quite work
I've been doing quite a bit of searching, but haven't been able to find
I use git both for Mac and PC. When pulling Mac's git from PC,
Just a general database design question - no programming, but a bit of problem
I have seen both examples quite a bit. Let's say you have <div class=contentHere></div>
This is a more general question: I have a quite complicated files table in

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.