Is it possible to create scrollbars like in this picture?
This picture was taken from this link: http://codesdirectory.blogspot.be/2013/01/wpf-scrollviewer-control-style.html . I tried the example in the post but the result looked like this:
The post is 3 years old so this may be normal.
Is it possible to create scrollbars like the first picture? I have been looking for hours to find a template and this is the closest I could get. I am converting a windows form app to a WPF and the main reason for that was the scrollbars! This is the xaml from the above pictures:
<Window x:Class="iBlock.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF ScrollViewer" SizeToContent="WidthAndHeight">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ScrollBar.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<ScrollViewer Background="#F7F7F7"
BorderBrush="#C7C7C7"
Height="300"
HorizontalScrollBarVisibility="Auto"
Margin="10"
Style="{DynamicResource ResourceKey=styleScrollViewer}"
VerticalScrollBarVisibility="Auto"
Width="400">
<StackPanel Background="Red" Height="400" Width="500"></StackPanel>
</ScrollViewer>
</Grid>
</Window>
4条答案
按热度按时间s4chpxco1#
在一些研究的帮助下得到了它的工作:
efzxgjgh2#
好的,Danny的代码有一些问题。当我试图激活水平滚动条时,它非常小
old scroll bar
所以我找到了解决办法。你必须创造一个像我这样的新风格:
然后更改水平滚动条模板中的缩略图样式
所以现在看起来不错
chhqkbe13#
我从上一个答案(ice thailand)的代码中删除了过时的元素,并稍微调整了一下页边空白。这是我现在使用的资源:
xuo3flqw4#
感谢您发送编修。
在我使用了他们的代码后,在右下角固定了一个方块。然后完成的代码如下。
你可以创建一个新的资源字典文件名为"Scrollbar.xaml"然后把这些代码
并且在App.xaml文件中
将此代码
然后在view. xaml文件中使用它,