Xaml 在Windows Phone中选择时,如何将颜色或纹理图像应用于LoopingSelector?

Xaml 在Windows Phone中选择时,如何将颜色或纹理图像应用于LoopingSelector?,xaml,windows-phone-7,windows-phone-8,expression-blend,Xaml,Windows Phone 7,Windows Phone 8,Expression Blend,如何在LoopingSelector中应用颜色或背景图像?属性中没有此控件的选项。那么我们如何将颜色应用于此控件,如下图所示 您可以选择修改loopingselector样式,修改样式模板中的网格背景 <Style TargetType="primitives:LoopingSelectorItem"> <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>

如何在LoopingSelector中应用颜色或背景图像?属性中没有此控件的选项。那么我们如何将颜色应用于此控件,如下图所示


您可以选择修改loopingselector样式,修改样式模板中的网格背景

<Style TargetType="primitives:LoopingSelectorItem">
    <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
    <Setter Property="Padding" Value="6"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Border x:Name="root" Opacity="0" CacheMode="BitmapCache" Background="Transparent" Padding="{TemplateBinding Padding}">

                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">

                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.2"/>
                            </VisualStateGroup.Transitions>

                            <VisualState x:Name="Normal"/>

                            <VisualState x:Name="Expanded">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="root" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                    <DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="0" Duration="0"/>
                                    <DoubleAnimation Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".6" Duration="0"/>
                                </Storyboard>
                            </VisualState>

                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="root" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                    <DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                </Storyboard>
                            </VisualState>

                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>

                    <Border.RenderTransform>
                        <TranslateTransform x:Name="Transform"/>
                    </Border.RenderTransform>

                    <Grid>
                        <Rectangle x:Name="background" Margin="2" Opacity="0" Fill="{StaticResource PhoneInactiveBrush}" CacheMode="BitmapCache"/>

                        <Border BorderThickness="2" BorderBrush="{StaticResource PhoneInactiveBrush}">
                            <ContentPresenter x:Name="contentPresenter" CacheMode="BitmapCache"/>
                        </Border>
                    </Grid>

                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


这些效果与Storyboad混合后很容易实现

您能提供更多描述,请回答。