6
A
回答
10
您可以更改Scrolling
狀態的VisualState
。您想編輯列表框的ScrollViewer's
VerticalScrollBar模板。例如,這種風格是100%不透明度和紅色:
<Style x:Key="ScrollViewerStyle1" TargetType="ScrollViewer">
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ScrollStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Scrolling">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="VerticalScrollBar"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HorizontalScrollBar"/>
</Storyboard>
</VisualState>
<VisualState x:Name="NotScrolling"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Margin="{TemplateBinding Padding}">
<ScrollContentPresenter x:Name="ScrollContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
<ScrollBar x:Name="VerticalScrollBar" HorizontalAlignment="Right" Height="Auto" IsHitTestVisible="False" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Opacity="0" Orientation="Vertical" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" VerticalAlignment="Stretch" Width="5" Background="Red"/>
<ScrollBar x:Name="HorizontalScrollBar" HorizontalAlignment="Stretch" Height="5" IsHitTestVisible="False" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Opacity="0" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}" VerticalAlignment="Bottom" Width="Auto"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
和ListBox's
風格(使用VerticalScrollBar模板以上)是這樣的:
<Style x:Key="ListBoxStyle1" TargetType="ListBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}" Style="{StaticResource ScrollViewerStyle1}" >
<ItemsPresenter/>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
您可以使用Expression Blend
手藝的XAML因爲它更有效率。
0
覆蓋scrollviewer的模板。
相關問題
- 1. 如何更改Windows Phone 7中的滾動條顏色
- 2. 從cs(windows phone 7)更改TextBlock顏色
- 3. 更改iframe中滾動條的顏色
- 4. 更改滾動條的顏色
- 5. 如何更改滾動條的顏色
- 6. 如何更改滾動條的顏色
- 7. 按鈕顏色-Windows Phone 7
- 8. C#Windows Phone 7 ListBox滾動向上/向下事件?
- 9. Windows Phone 7 listbox着色項目?
- 10. 更改JScrollPane滾動條顏色
- 11. 更改UITextView滾動條顏色
- 12. 如何更改eclipse滾動條顏色
- 13. Windows Phone 7:使ListBox項目動態更改
- 14. 更改WP7上Listbox的顏色屬性
- 15. Windows Phone 7(WP7)點擊更改按鈕的背景顏色
- 16. 在windows phone 7中更改鍵盤的顏色?
- 17. 更改Windows Phone 7主題感知應用程序的顏色
- 18. 改圈顏色應用程序欄上的Windows Phone 7
- 19. 如何滾動到Windows Phone 7中的ListBox的頂部?
- 20. 更改滾動條上的引導導航欄的顏色
- 21. 在滾動上更改顏色
- 22. 如何更改網頁上滾動條的顏色?
- 23. 如何更改滾動條上標記的顏色?
- 24. 在Windows Phone 7上滾動WebBrowser控件
- 25. Windows Phone ListBox滾動到末尾
- 26. 如何使Windows Phone Listbox不可滾動?
- 27. 更改Windows 7窗口顏色
- 28. 在滾動條上更改標題和菜單顏色
- 29. 改變滾動條的顏色?
- 30. Windows Phone 7 - Silverlight對號顏色
謝謝,像魔術般的作品:D – 0xFF 2011-06-10 13:19:08
@keyboardP它的工作原理,起初我想到改變前景 – onmyway133 2012-11-20 08:59:44