WP8 - PlayerFramework幻灯片模板

时间:2013-06-27 12:33:52

标签: templates styles media-player media

我正在尝试为Windows Phone 8实现播放器框架媒体播放器的黑暗主题,我似乎无法使某些东西发挥作用。

我正在通过添加模板来改变可搜索滑块的样式(就像在win8版本中一样,完美地工作),但是在wp8上我可以看到滑块拇指,但是它不会移动并且使用了矩形填写栏没有显示。

以下是可搜索滑块样式的代码:

<Style TargetType="mmppf:SeekableSlider" x:Key="Dark_SeekableSlider">
    <Setter Property="IsTabStop" Value="True" />
    <Setter Property="Padding" Value="0" />
    <Setter Property="Background" Value="{StaticResource Dark_SliderTrackBackgroundThemeBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource Dark_SliderBorderThemeBrush}" />
    <Setter Property="BorderThickness" Value="{StaticResource Dark_SliderBorderThemeThickness}" />
    <Setter Property="Foreground" Value="{StaticResource Dark_SliderTrackDecreaseBackgroundThemeBrush}" />
    <Setter Property="SliderTrackDecreasePressedBackground" Value="{StaticResource Dark_SliderTrackDecreasePressedBackgroundThemeBrush}" />
    <Setter Property="SliderTrackPressedBackground" Value="{StaticResource Dark_SliderTrackPressedBackgroundThemeBrush}" />
    <Setter Property="SliderThumbPressedBackground" Value="{StaticResource Dark_SliderThumbPressedBackgroundThemeBrush}" />
    <Setter Property="SliderThumbPressedBorder" Value="{StaticResource Dark_SliderThumbPressedBorderThemeBrush}" />
    <Setter Property="SliderDisabledBorder" Value="{StaticResource Dark_SliderDisabledBorderThemeBrush}" />
    <Setter Property="SliderTrackDecreaseDisabledBackground" Value="{StaticResource Dark_SliderTrackDecreaseDisabledBackgroundThemeBrush}" />
    <Setter Property="SliderTrackDisabledBackground" Value="{StaticResource Dark_SliderTrackDisabledBackgroundThemeBrush}" />
    <Setter Property="SliderThumbDisabledBackground" Value="{StaticResource Dark_SliderThumbDisabledBackgroundThemeBrush}" />
    <Setter Property="SliderTrackDecreasePointerOverBackground" Value="{StaticResource Dark_SliderTrackDecreasePointerOverBackgroundThemeBrush}" />
    <Setter Property="SliderTrackPointerOverBackground" Value="{StaticResource Dark_SliderTrackPointerOverBackgroundThemeBrush}" />
    <Setter Property="SliderThumbPointerOverBackground" Value="{StaticResource Dark_SliderThumbPointerOverBackgroundThemeBrush}" />
    <Setter Property="SliderThumbPointerOverBorder" Value="{StaticResource Dark_SliderThumbPointerOverBorderThemeBrush}" />
    <Setter Property="SliderThumbBackground" Value="{StaticResource Dark_SliderThumbBackgroundThemeBrush}" />
    <Setter Property="SliderThumbStyle">
        <Setter.Value>
            <Style TargetType="Thumb">
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="{StaticResource Dark_SliderThumbBorderThemeBrush}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Thumb">
                            <Border Background="{TemplateBinding Background}" Height="{StaticResource Dark_SliderTrackThemeHeight}" Width="{StaticResource Dark_SliderTrackThemeHeight}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="mmppf:SeekableSlider">
                <Grid x:Name="LayoutRoot">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreasePressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackPressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPressedBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreasePressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackPressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPressedBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalBorder" Storyboard.TargetProperty="Stroke">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderDisabledBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalBorder" Storyboard.TargetProperty="Stroke">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderDisabledBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreaseDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreaseDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbDisabledBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreasePointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackPointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPointerOverBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalDecreaseRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackDecreasePointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalTrackRect" Storyboard.TargetProperty="Fill">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderTrackPointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPointerOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalThumb" Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding SliderThumbPointerOverBorder, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused" />
                            <VisualState x:Name="PointerFocused" />
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid x:Name="HorizontalTemplate" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ContentPresenter x:Name="HorizontalBackgroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding HorizontalBackgroundContent}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
                        <Rectangle x:Name="HorizontalTrackRect" Margin="{TemplateBinding Padding}" Grid.Row="1" Fill="{TemplateBinding Background}" Grid.Column="0" Grid.ColumnSpan="3" IsHitTestVisible="False" />
                        <Rectangle x:Name="HorizontalDecreaseRect" Margin="{TemplateBinding Padding}" Grid.Row="1" Fill="{TemplateBinding Foreground}" Grid.Column="0" IsHitTestVisible="False" />
                        <Rectangle x:Name="HorizontalBorder" Margin="{TemplateBinding Padding}" Grid.RowSpan="3" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="3" IsHitTestVisible="False" />
                        <Border x:Name="HorizontalAvailableBar" Grid.RowSpan="3" Grid.ColumnSpan="3" HorizontalAlignment="Left" IsHitTestVisible="True" Background="#00000000" />
                        <ContentPresenter Visibility="Visible" x:Name="HorizontalForegroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding HorizontalForegroundContent}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
                        <Thumb x:Name="HorizontalThumb" Background="{TemplateBinding SliderThumbBackground}" Style="{TemplateBinding SliderThumbStyle}" DataContext="{TemplateBinding Value}" Grid.Row="1" Grid.Column="1" Height="{StaticResource Dark_SliderTrackThemeHeight}" Width="{StaticResource Dark_SliderTrackThemeHeight}"/>
                    </Grid>
                    <Grid x:Name="VerticalTemplate">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <ContentPresenter x:Name="VerticalBackgroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding VerticalBackgroundContent}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
                        <Rectangle x:Name="VerticalTrackRect" Margin="{TemplateBinding Padding}" Grid.Column="1" Fill="{TemplateBinding Background}" Grid.Row="0" Grid.RowSpan="3" IsHitTestVisible="False" />
                        <Rectangle x:Name="VerticalDecreaseRect" Margin="{TemplateBinding Padding}" Grid.Column="1" Fill="{TemplateBinding Foreground}" Grid.Row="2" IsHitTestVisible="False" />
                        <Rectangle x:Name="VerticalBorder" Margin="{TemplateBinding Padding}" Grid.ColumnSpan="3" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="3" IsHitTestVisible="False" />
                        <Border x:Name="VerticalAvailableBar" Grid.ColumnSpan="3" Grid.RowSpan="3" VerticalAlignment="Bottom" IsHitTestVisible="True" Background="#00000000" />
                        <ContentPresenter x:Name="VerticalForegroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding VerticalForegroundContent}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
                        <Thumb x:Name="VerticalThumb" Background="{TemplateBinding SliderThumbBackground}" Style="{TemplateBinding SliderThumbStyle}" DataContext="{TemplateBinding Value}" Grid.Row="1" Grid.Column="1" Height="{StaticResource Dark_SliderTrackThemeHeight}" Width="{StaticResource Dark_SliderTrackThemeHeight}"/>
                    </Grid>
                    <Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Stroke="{StaticResource Dark_FocusVisualWhiteStrokeThemeBrush}" StrokeEndLineCap="Square" StrokeDashArray="1,1" Opacity="0" StrokeDashOffset="1.5" Margin="-5" />
                    <Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" Stroke="{StaticResource Dark_FocusVisualBlackStrokeThemeBrush}" StrokeEndLineCap="Square" StrokeDashArray="1,1" Opacity="0" StrokeDashOffset="0.5" Margin="-5" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

是不是wp8无法处理相同的主题?虽然在播放器框架网站上,它与Windows 8和Windows Phone 8的样本主题相同。

使用这些模板:

<Grid x:Name="HorizontalTemplate">
                        <ContentPresenter x:Name="HorizontalBackgroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding HorizontalBackgroundContent}"/>
                        <Rectangle x:Name="HorizontalTrack" Margin="{TemplateBinding Padding}" Fill="{TemplateBinding Background}" IsHitTestVisible="False" />
                        <Rectangle x:Name="HorizontalFill" Margin="{TemplateBinding Padding}" Fill="{TemplateBinding Foreground}" IsHitTestVisible="False">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0, 0, 6, 15"/>
                            </Rectangle.Clip>
                        </Rectangle>
                        <Border x:Name="HorizontalAvailableBar" HorizontalAlignment="Left" IsHitTestVisible="True" Background="#00000000" />
                        <ContentPresenter x:Name="HorizontalForegroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding HorizontalForegroundContent}"/>
                        <Rectangle x:Name="HorizontalCenterElement" Fill="{TemplateBinding SliderThumbBackground}" DataContext="{TemplateBinding Value}" HorizontalAlignment="Left" Width="{StaticResource Dark_SliderTrackThemeHeight}">
                            <Rectangle.RenderTransform>
                                <TranslateTransform/>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                    </Grid>
                    <Grid x:Name="VerticalTemplate" Visibility="Collapsed">
                        <ContentPresenter x:Name="VerticalBackgroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding VerticalBackgroundContent}"/>
                        <Rectangle x:Name="VerticalTrack" Margin="{TemplateBinding Padding}" Fill="{TemplateBinding Background}" IsHitTestVisible="False" Width="{StaticResource Dark_SliderTrackThemeHeight}"/>
                        <Rectangle x:Name="VerticalFill" Margin="{TemplateBinding Padding}" Fill="{TemplateBinding Foreground}" IsHitTestVisible="False" Width="{StaticResource Dark_SliderTrackThemeHeight}">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0, 0, 15, 6"/>
                            </Rectangle.Clip>
                        </Rectangle>
                        <Border x:Name="VerticalAvailableBar" VerticalAlignment="Bottom" IsHitTestVisible="True" Background="#00000000" />
                        <ContentPresenter x:Name="VerticalForegroundContentPresenter" Margin="{TemplateBinding Padding}" Content="{TemplateBinding VerticalForegroundContent}"/>
                        <Rectangle x:Name="VerticalCenterElement" Fill="{TemplateBinding SliderThumbBackground}" DataContext="{TemplateBinding Value}" VerticalAlignment="Top" Height="{StaticResource Dark_SliderTrackThemeHeight}">
                            <Rectangle.RenderTransform>
                                <TranslateTransform/>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                    </Grid>

0 个答案:

没有答案