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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:39:48+00:00 2026-05-15T03:39:48+00:00

I’ve a created a simple scrollviewer (pnlDayScroller) and want to have a separate horizontal

  • 0

I’ve a created a simple scrollviewer (pnlDayScroller) and want to have a separate horizontal scrollbar (associated scroller) to do the horizontal scrolling. All works with the below code accept I need to bind the visibility of the associated scroller.

I can’t simply bind this to the visibility property of the horizontal template part of the scroll viewer as I’ve set this to be always hidden. The only way I can think to do this is to bind the visibility of the associated scroller to a function such that

If associatedScroller.scrollableWidth > 0 then 
    associatedScroller.visibility = visibility.visible
else
    associatedScroller.visibility = visibility.collapsed
end if

Is this possible to do and if so how do I do it?

    Private Sub pnlDayScroller_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles pnlDayScroller.Loaded

        Dim binViewport, binMax, binMin, binSChange, binLChange As Binding


        Dim horizontalScrollBar As Primitives.ScrollBar = CType(pnlDayScroller.Template.FindName("PART_HorizontalScrollBar", pnlDayScroller), Primitives.ScrollBar)

        binViewport = New Binding("ViewportSize")
        binViewport.Mode = BindingMode.OneWay
        binViewport.Source = horizontalScrollBar
        associatedScroller.SetBinding(Primitives.ScrollBar.ViewportSizeProperty, binViewport)

        binMax = New Binding("Maximum")
        binMax.Mode = BindingMode.OneWay
        binMax.Source = horizontalScrollBar
        associatedScroller.SetBinding(Primitives.ScrollBar.MaximumProperty, binMax)

        binMin = New Binding("Minimum")
        binMin.Mode = BindingMode.OneWay
        binMin.Source = horizontalScrollBar
        associatedScroller.SetBinding(Primitives.ScrollBar.MinimumProperty, binMin)

        binSChange = New Binding("SmallChange")
        binSChange.Mode = BindingMode.OneWay
        binSChange.Source = horizontalScrollBar
        associatedScroller.SetBinding(Primitives.ScrollBar.SmallChangeProperty, binSChange)

        binLChange = New Binding("LargeChange")
        binLChange.Mode = BindingMode.OneWay
        binLChange.Source = horizontalScrollBar
        associatedScroller.SetBinding(Primitives.ScrollBar.LargeChangeProperty, binLChange)
End Sub

  Private Sub associatedScroller_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of Double)) Handles associatedScroller.ValueChanged
        pnlDayScroller.ScrollToHorizontalOffset(e.NewValue)
end sub

FOLLOW UP (thanks to JustABill) :

I’ve add this code into the pnlDayScroller sub above (I’ve discovered scrollableWidth is a property of scrollviewer not scrollbar, but the maximum property gives a result I can use instead)

binVisibility = New Binding("Maximum")
    binVisibility.Mode = BindingMode.OneWay
    binVisibility.Source = horizontalScrollBar
    binVisibility.Converter = New ScrollableConverter
    associatedScroller.SetBinding(Primitives.ScrollBar.VisibilityProperty, binVisibility)

and I’ve created this class

 Public Class ScrollableConverter
        Implements IValueConverter

            Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object,
            ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert

            Dim dblMaximum As Double

            If targetType IsNot GetType(Visibility) Then
                Throw New InvalidOperationException("The target must be a visibility")
            Else


                dblMaximum = CType(value, Double)
                Debug.WriteLine("Value of double is " & dblMaximum)

                If dblMaximum > 0 Then
                    Return Visibility.Visible
                Else
                    Return Visibility.Collapsed
                End If
            End If

        End Function

        Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object,
            ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack

            Throw New NotSupportedException()
        End Function

End Class

And the problem is resolved.

  • 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-15T03:39:49+00:00Added an answer on May 15, 2026 at 3:39 am

    You need a ValueConverter. Bind to the scrollableWidth property, and add your ValueConverter to the binding’s Converter property. That example’s in C#, but the concept’s pretty simple, and I’m sure there’s VB.Net examples around if you look.

    The short form of what you need to do is:

    1. Create a new class that implements IValueConverter (I think it’s in System.ComponentModel).
    2. Fill in the Convert method with your first code block, except use the “value” parameter instead of scrollableWidth and return the visibility.
    3. Add an appropriate xmlns for your local classes.
    4. Add a StaticResource of your new ValueConverter to your Window/UserControl/whatever.
    5. Bind the Visibility property to the scrollableWidth property using this ValueConverter.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
In order to apply a triggered animation to all ToolTip s in my app,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.