如何更改Windows Phone 7中的滚动条颜色

时间:2013-05-10 05:11:25

标签: windows-phone-7 silverlight-4.0 scrollbar

请告诉我任何一个如何更改Windows Phone 7中的滚动条颜色,我还要自定义Windows Phone 7中的滚动条。

2 个答案:

答案 0 :(得分:0)

您是否尝试在滚动条所在的xaml代码中使用“背景属性?

试试这个:

<ScrollBar Background="Green" HorizontalAlignment="Left" Margin="299,144,0,0" VerticalAlignment="Top"/>

不要使用整个东西,我想让你从中获取它是你应该有一行类似于此的xaml代码,只需像我一样输入背景属性。希望这更清楚。

答案 1 :(得分:0)

如果您对将其编码到XAML感到满意,请找到答案here。或者,最短也是最简单的方法是使用 Expression Blend

我在其他地方找到的片段:

<ListBox x:Name="myListBox">
<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" Background="Blue" 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"/>
            <ScrollBar x:Name="HorizontalScrollBar" Background="Blue"  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>

希望这一切对你有所帮助:)。