Hello,
Welcome to our Microsoft Q&A platform!
Can you elaborate on the use of ScrollViewer
? And, it would be very helpful if you could show the problematic code
For ScrollBar, there are four key settings:
- Maximum: used to determine the height of the entire scrollable content
- ViewportSize: used to determine the size of the visible window
- Orientation: scroll direction
- IndicatorMode: This is the key to displaying the ScrollBar
When using the keyboard and mouse, you can set the IndicatorMode
to MouseIndicator
(the default is None
). After setting, the ScrollBar
can be displayed.
But this does not mean that the ScrollBar
can implement the scrolling function. You need to listen to the ScrollBar.Scroll
event and implement the scrolling effect yourself according to the event parameters (this may be complicated).
If there is no special need, using ScrollViewer
is a common practice.
Update
You can assign a value to ScrollBar.IndicatorMode
through the way that AnalyticsInfo.VersionInfo.DeviceFamily
judges the current device, or determine the device type when the pointer is moved over (listen the PointerEntered event).
private void Grid_PointerEntered(object sender, PointerRoutedEventArgs e)
{
var pointer = e.GetCurrentPoint(sender as UIElement);
if (pointer.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
TestScrollBar.IndicatorMode = ScrollingIndicatorMode.MouseIndicator;
}
// ... other case
}
As for how to make the ScrollBar
always appear, this is more difficult. The show / hide animation you see, and the internal switching logic, this is the internal implementation of the ScrollBar
. You can find the default Style of ScrollBar
in generic.xaml and try to modify some animation effects.
In the case of general labor, the address of generic.xaml
is located at: your_sdk_drive:\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\your_system_version\Generic
. You can also find a default resource reference, move the cursor to the resource name, press F12 to jump to generic.xaml
to find the style resource of TargetType =" ScrollBar "
Thanks.