1. 程式人生 > >WPF ScrollViewer 固定滑塊的最小高度

WPF ScrollViewer 固定滑塊的最小高度

<Track x:Name="PART_Track" IsDirectionReversed="True"   Grid.Row="1" HorizontalAlignment="Stretch"  ViewportSize="NaN" >               
                <Track.Thumb>
                    <Thumb Template="{StaticResource ThumbTemplate}"  MinHeight="40"  HorizontalAlignment="Stretch"/>
                </Track.Thumb>

當列表中的節點數量過多時,如果用ScrollViewer的話會導致垂直滾動條的滑塊非常的小,影響使用者操作。這裡需要感謝  https://www.cnblogs.com/cody1988/p/wpf_ScrollBar.html

解決方案,重寫滾動條模板,並將模板中 Track 的屬性設定為  ViewportSize="NaN"  這樣就可以自定義滑塊Thumb的最小高度   MinHeight="40"