2010-03-28 51 views
1

我已經採取了MSDN模板樣式的滾動條,並已嘗試應用(在每個軌道中繼器和獨立的圖像上的拇指圖片)我的不同風格但我無法改變拇指大小。我爲什麼不能得到一個拇指上一些風格的滾動條較大的WPF

我曾嘗試在Track.Thumb風格,並在拇指本身的控件模板設置寬度。出於某種原因,即使拇指實際佔用更多空間,也只能渲染默認尺寸。有誰知道如何使拇指呈現我想要的尺寸?

我使用了樣式的XAML是在這裏:

<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"> 
     <Setter Property="Background" Value="Red" /> 
     <Setter Property="OverridesDefaultStyle" Value="True"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Thumb}"> 
        <Image Source="sampleimg.png" Stretch="Fill" />       
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

    <ControlTemplate x:Key="ArfleHBar" TargetType="{x:Type ScrollBar}"> 
     <Grid > 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition MaxWidth="18"/> 
       <ColumnDefinition Width="0.00001*"/> 
       <ColumnDefinition MaxWidth="18"/> 
      </Grid.ColumnDefinitions>    
      <RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineLeftCommand" Content="M 4 0 L 4 8 L 0 4 Z" /> 
      <Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False" >      
       <Track.DecreaseRepeatButton> 
        <RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" Width="100"/> 
       </Track.DecreaseRepeatButton> 
       <Track.Thumb> 
        <Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,1,0,1" Width="250" Padding="0,0,0,0">        
        </Thumb> 
       </Track.Thumb> 
       <Track.IncreaseRepeatButton> 
        <RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" Width="100" /> 
       </Track.IncreaseRepeatButton>      
      </Track> 
      <RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineRightCommand" Content="M 0 0 L 4 4 L 0 8 Z"/> 
     </Grid> 
    </ControlTemplate> 

    <Style x:Key="ArfleBar" TargetType="{x:Type ScrollBar}"> 
     <Setter Property="SnapsToDevicePixels" Value="True"/> 
     <Setter Property="OverridesDefaultStyle" Value="true"/> 
     <Style.Triggers> 
      <Trigger Property="Orientation" Value="Horizontal"> 
       <Setter Property="Width" Value="Auto"/> 
       <Setter Property="Height" Value="18" /> 
       <Setter Property="Template" Value="{StaticResource ArfleHBar}" /> 
      </Trigger>     
     </Style.Triggers> 
    </Style> 

回答

2

我不知道這是否是你正在尋找的答案,因爲我從來沒有嘗試過對皮膚有滾動條,但你可以改變通過修改一些系統屬性的條寬/高:

<ScrollViewer> 
    <ScrollViewer.Resources> 
     <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">17</sys:Double> 
     <sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">17</sys:Double> 
    </ScrollViewer.Resources> 

    ... 

</ScrollViewer> 
+0

謝謝,但我相信這些是隻讀設置,以使您的控件顯示爲系統控件。除非你知道改變這個特定滾動條的方法,否則我認爲這不會解決這個問題。感謝你的回答。 – Tollo 2010-03-30 14:48:46

+0

只讀設置?不,再看看他們: 17 你可以改變這些值。我用17,但你可以使用800,如果你想要一些大胖子滾動條... 這些參數並不意味着要啓用自定義控制,看起來像系統控制,而是要改變系統控制的外觀!如果我在這個例子中使用17,這是因爲它似乎是系統默認值,但我需要確保,所以我硬編碼了。 – 2010-03-30 15:06:35

+0

真棒你是對的,對不起,我誤解了我在看書。非常感謝!我找到了這裏解釋它的樣本。 http://msdn.microsoft.com/en-us/library/bb395201.aspx – Tollo 2010-03-30 20:25:33

相關問題