直接上代码了 自己理解去吧
<phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:interactions="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" xmlns:SimpleMvvmToolkit="clr-namespace:SimpleMvvmToolkit;assembly=SimpleMvvmToolkit-WP7" x:Class="Think.MTV.Views.VideoPlayer" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Landscape" Orientation="Landscape" mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800" DataContext="{Binding VideoPlayerViewModel,Source={StaticResource Locator}}" shell:SystemTray.IsVisible="False"> <i:Interaction.Triggers> <i:EventTrigger> <SimpleMvvmToolkit:EventToCommand Command="{Binding LoadCommand, Mode=OneWay}"/> </i:EventTrigger> </i:Interaction.Triggers> <!--LayoutRoot 是包含所有页面内容的根网格--> <Grid x:Name="LayoutRoot" Background="Transparent"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="PlayPauseButtons"> <VisualState x:Name="PlayButtonOn"> <!-- Switch to play button storyboard --> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PauseButton"> <DiscreteObjectKeyFrame KeyTime="0:0:0.2"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> <DiscreteObjectKeyFrame KeyTime="0:0:0.5"> <DiscreteObjectKeyFrame.Value> <Visibility> Collapsed </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PlayButton"> <DiscreteObjectKeyFrame KeyTime="0:0:0.5"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="PauseButtonOn"> <!-- Switch to pause button storyboard --> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PlayButton"> <DiscreteObjectKeyFrame KeyTime="0:0:0.2"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> <DiscreteObjectKeyFrame KeyTime="0:0:0.5"> <DiscreteObjectKeyFrame.Value> <Visibility> Collapsed </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PauseButton"> <DiscreteObjectKeyFrame KeyTime="0:0:0.5"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="PlayerControlsAnimations"> <VisualState x:Name="PlayerControlsBoxHidden"> <!-- Hide controls storyboard --> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PlayerControls"> <DiscreteObjectKeyFrame KeyTime="0:0:0.1"> <DiscreteObjectKeyFrame.Value> <Visibility> Collapsed </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerControls"> <EasingDoubleKeyFrame KeyTime="0" Value="1" /> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="PlayerControlsShown"> <!-- Show controls storyboard --> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PlayerControls"> <DiscreteObjectKeyFrame KeyTime="0:0:0.1"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerControls"> <EasingDoubleKeyFrame KeyTime="0" Value="0" /> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0" /> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <i:Interaction.Behaviors> <interactions:DataStateBehavior Binding="{Binding ShowControls,Mode=TwoWay}" Value="true" TrueState="PlayerControlsShown" FalseState="PlayerControlsBoxHidden"/> <interactions:DataStateBehavior Binding="{Binding PlayButtonVisible}" Value="true" TrueState="PlayButtonOn" FalseState="PauseButtonOn" /> </i:Interaction.Behaviors> <!--ContentPanel - 在此处放置其他内容--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Grid x:Name="Player" Grid.Row="0" Grid.Column="0" RenderTransformOrigin="0.5,0.5" Margin="0,1,0,0" Grid.RowSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center"> <MediaElement x:Name="mediaElement" Source="{Binding SelectedVideoMediaUrl,Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center" AutoPlay="False" d:LayoutOverrides="Width" Cursor="Arrow" Volume="1"> <i:Interaction.Triggers> <i:EventTrigger EventName="MediaOpened"> <SimpleMvvmToolkit:EventToCommand Command="{Binding MediaOpenedCommand}" CommandParameter="{Binding ElementName=mediaElement, Mode=OneWay}"/> </i:EventTrigger> <i:EventTrigger EventName="MouseLeftButtonDown"> <SimpleMvvmToolkit:EventToCommand Command="{Binding ShowPlayerControlsCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> <!--<i:Interaction.Triggers> <i:EventTrigger EventName="MediaOpened"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding MediaOpenedCommand}" CommandParameter="{Binding ElementName=mediaElement, Mode=OneWay}" /> </i:EventTrigger> <i:EventTrigger EventName="MediaEnded"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding MediaEndedCommand}" /> </i:EventTrigger> <i:EventTrigger EventName="MouseLeftButtonDown"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding ShowPlayerControlsCommand}" /> </i:EventTrigger> </i:Interaction.Triggers>--> </MediaElement> </Grid> <Grid x:Name="PlayerControls" d:LayoutOverrides="GridBox" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="0" RenderTransformOrigin="0.5,0.5" Height="117" Background="#B2000000" Visibility="Collapsed"> <Grid.RenderTransform> <CompositeTransform /> </Grid.RenderTransform> <Grid.ColumnDefinitions> <ColumnDefinition Width="120" /> <ColumnDefinition Width="0.773*" /> </Grid.ColumnDefinitions> <!--<i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding ResetHideControlsCommand}" /> </i:EventTrigger> </i:Interaction.Triggers>--> <Border x:Name="ProgressInfo" Grid.Column="1" BorderThickness="0" CornerRadius="0"> <Grid Margin="0,12,12,12"> <Grid.RowDefinitions> <RowDefinition Height="61" /> <RowDefinition Height="24" /> </Grid.RowDefinitions> <TextBlock x:Name="ProgressDisplay" Text="{Binding CurrentProgress}" Height="32" TextAlignment="Right" RenderTransformOrigin="0.5,0.5" Grid.Row="1" Margin="0" FontSize="15" FontFamily="Segoe WP Light" VerticalAlignment="Top" Foreground="White"> <TextBlock.RenderTransform> <CompositeTransform /> </TextBlock.RenderTransform> </TextBlock> <ProgressBar x:Name="progressBar" Grid.Row="0" Maximum="{Binding TotalDuration}" Value="{Binding CurrentPosition}" Margin="0,32,0,5" Height="Auto" Style="{StaticResource PhoneProgressBarStyle}" Foreground="{StaticResource PhoneAccentBrush}" /> <Rectangle Height="40" Fill="#00000000" VerticalAlignment="Bottom"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <SimpleMvvmToolkit:EventToCommand Command="{Binding SeekCommand}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> </Grid> </Border> <Border x:Name="Controls" Grid.Column="0" BorderThickness="0" CornerRadius="0" Margin="0,0,0,0"> <StackPanel Orientation="Horizontal"> <Button Visibility="Visible" x:Name="PlayButton" Content="Play" Width="120" Height="80" Style="{StaticResource PhoneButtonStylePlay}" Margin="0,19,0,18"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <SimpleMvvmToolkit:EventToCommand Command="{Binding PauseVideoCommand}" /> <!-- <SimpleMvvmToolkit:EventToCommand Command="{Binding ResetHideControlsCommand}" />--> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button Visibility="Collapsed" x:Name="PauseButton" Content="Play" Width="120" Height="80" Style="{StaticResource PhoneButtonStylePause}" Margin="0,19,0,18"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <SimpleMvvmToolkit:EventToCommand Command="{Binding PauseVideoCommand}" /> <!-- <SimpleMvvmToolkit:EventToCommand Command="{Binding ResetHideControlsCommand}" />--> </i:EventTrigger> </i:Interaction.Triggers> </Button> </StackPanel> </Border> </Grid> </Grid> </Grid> </phone:PhoneApplicationPage>
using System; using System.Windows; using System.Threading; using System.Collections.ObjectModel; // Toolkit namespace using SimpleMvvmToolkit; // Toolkit extension methods using SimpleMvvmToolkit.ModelExtensions; using Think.MTV.Services; using Think.Model; using System.Windows.Input; using System.Windows.Controls; using System.IO; using System.Windows.Threading; namespace Think.MTV.ViewModels { /// <summary> /// This class contains properties that a View can data bind to. /// <para> /// Use the <strong>mvvmprop</strong> snippet to add bindable properties to this ViewModel. /// </para> /// </summary> public class VideoPlayerViewModel : ViewModelBase<VideoPlayerViewModel> { #region Initialization and Cleanup // TODO: Add a member for IXxxServiceAgent private IVideoServiceAgent serviceAgent; // Default ctor public VideoPlayerViewModel() { } // TODO: ctor that accepts IXxxServiceAgent public VideoPlayerViewModel(IVideoServiceAgent serviceAgent) { this.serviceAgent = serviceAgent; if (videoMediaElement != null) Play(videoMediaElement); DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 5) }; this.hideControlsTimer = timer; this.hideControlsTimer.Tick += new EventHandler(hideControlsTimer_Tick); DispatcherTimer timer2 = new DispatcherTimer { Interval = new TimeSpan(0, 0, 5) }; } void hideControlsTimer_Tick(object sender, EventArgs e) { if (this.ShowControls) { this.ShowControls = false; } } #endregion #region Notifications // TODO: Add events to notify the view or obtain data from the view public event EventHandler<NotificationEventArgs<Exception>> ErrorNotice; #endregion #region Properties private DispatcherTimer hideControlsTimer; private DispatcherTimer hideExplicitTimer; private DispatcherTimer videoProgressTimer; private MediaElement videoMediaElement; private bool showControls; public bool ShowControls { get { return showControls; } set { showControls = value; if (value) { this.hideControlsTimer.Start(); } else { this.hideControlsTimer.Stop(); } this.NotifyPropertyChanged(p => p.ShowControls); } } private bool _PlayButtonVisible; public bool PlayButtonVisible { get { return _PlayButtonVisible; } set { _PlayButtonVisible = value; this.NotifyPropertyChanged(p => p.PlayButtonVisible); } } private string currentProgress; public string CurrentProgress { get { return this.currentProgress; } set { this.currentProgress = value; this.NotifyPropertyChanged(p => p.CurrentProgress); } } private double currentPosition; public double CurrentPosition { get { return this.currentPosition; } set { this.currentPosition = value; this.NotifyPropertyChanged(p => p.CurrentPosition); } } private double totalDuration; public double TotalDuration { get { return this.totalDuration; } set { this.totalDuration = value; this.NotifyPropertyChanged(p => p.TotalDuration); } } private Uri _SelectedVideoMediaUrl; public Uri SelectedVideoMediaUrl { get { return _SelectedVideoMediaUrl; } set { _SelectedVideoMediaUrl = value; this.NotifyPropertyChanged(p => p.SelectedVideoMediaUrl); } } private static Video myVideo; public static Video MyVideo { get { return myVideo; } set { myVideo = value; } } private VideoDetail _Video; public VideoDetail Video { get { return _Video; } set { _Video = value; } } // TODO: Add properties using the mvvmprop code snippet #endregion #region Command public ICommand LoadCommand { get { return new DelegateCommand(LoadData); } } public ICommand MediaOpenedCommand { get { return new DelegateCommand<MediaElement>(Play); } } public ICommand ShowPlayerControlsCommand { get { return new DelegateCommand(ShowPlayerControls); } } public ICommand SeekCommand { get { return new DelegateCommand<object>(OnSeekCommand); } } public ICommand PauseVideoCommand { get { return new DelegateCommand(PauseVideo); } } #endregion #region Methods public void PauseVideo() { if (this.videoMediaElement.CurrentState == System.Windows.Media.MediaElementState.Playing) { if (this.videoMediaElement.CanPause) { this.videoMediaElement.Pause(); this.PlayButtonVisible = true; } else { this.videoMediaElement.Stop(); } if (this.videoProgressTimer.IsEnabled) { this.videoProgressTimer.Stop(); } } else { this.videoMediaElement.Play(); this.videoProgressTimer.Start(); this.PlayButtonVisible = false; } } private void OnSeekCommand(object obj) { if (obj is MouseButtonEventArgs) { FrameworkElement element = (FrameworkElement)(obj as MouseButtonEventArgs).OriginalSource; double percentComplete = (obj as MouseButtonEventArgs).GetPosition(element).X / element.ActualWidth; this.Seek(percentComplete); } } private void Seek(double percentComplete) { int seconds = (int)(this.videoMediaElement.NaturalDuration.TimeSpan.TotalSeconds * percentComplete); this.videoMediaElement.Position = new TimeSpan(0, 0, seconds); this.SetCurrentPosition(); } private void ShowPlayerControls() { ShowControls = !ShowControls; } // TODO: Add methods that will be called by the view private void LoadData() { if (MyVideo != null && Video != MyVideo) serviceAgent.GetVideoData(MyVideo, (vd, error) => { Video = vd; SelectedVideoMediaUrl = new Uri(Video.VideoSrc); }); } private void Play(MediaElement me) { MediaElement element = me; this.videoMediaElement = element; me.Play(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = (TimeSpan.FromSeconds(1.0)); this.videoProgressTimer = timer; videoProgressTimer.Tick += new EventHandler(videoProgressTimer_Tick); this.SetCurrentPosition(); this.PlayVideo(null); } private void SetCurrentPosition() { if ((this.CurrentPosition > 0.0) && (this.CurrentPosition >= this.TotalDuration)) { this.CurrentPosition = 0.0; this.StopVideo(null); } int arg = this.videoMediaElement.Position.Seconds; this.CurrentProgress = string.Format("{0}:{1} / {2}:{3}", new object[] { Math.Floor(this.videoMediaElement.Position.TotalMinutes).ToString("00"), this.videoMediaElement.Position.Seconds.ToString("00"), Math.Floor(this.videoMediaElement.NaturalDuration.TimeSpan.TotalMinutes).ToString("00"), this.videoMediaElement.NaturalDuration.TimeSpan.Seconds.ToString("00") }); this.CurrentPosition = this.videoMediaElement.Position.TotalSeconds; this.TotalDuration = this.videoMediaElement.NaturalDuration.TimeSpan.TotalSeconds; } public void PlayVideo(object param) { this.videoMediaElement.Play(); this.videoProgressTimer.Start(); this.PlayButtonVisible = false; } public void StopVideo(object param) { this.videoMediaElement.Stop(); this.videoProgressTimer.Stop(); this.SetCurrentPosition(); } void videoProgressTimer_Tick(object sender, EventArgs e) { this.SetCurrentPosition(); } #endregion #region Completion Callbacks // TODO: Optionally add callback methods for async calls to the service agent #endregion #region Helpers // Helper method to notify View of an error private void NotifyError(string message, Exception error) { // Notify view of an error Notify(ErrorNotice, new NotificationEventArgs<Exception>(message, error)); } #endregion } }
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Style x:Key="PhoneProgressBarStyle" TargetType="ProgressBar"> <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}" /> <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Height" Value="4" /> <Setter Property="Maximum" Value="100" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ProgressBar"> <Grid x:Name="Root"> <Grid.Resources> <Style x:Key="PhoneProgressBarSliderStyle" TargetType="Slider"> <Setter Property="Maximum" Value="3000" /> <Setter Property="Minimum" Value="0" /> <Setter Property="Height" Value="8" /> <Setter Property="Value" Value="0" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Slider"> <Grid x:Name="Root"> <Grid.Resources> <ControlTemplate x:Key="SliderThumb" TargetType="Thumb"> <Ellipse Fill="{TemplateBinding Foreground}" Height="{TemplateBinding Width}" Width="{TemplateBinding Width}" /> </ControlTemplate> </Grid.Resources> <Grid x:Name="HorizontalTemplate" Background="{TemplateBinding Background}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.Column="2" Template="{x:Null}" /> <Thumb x:Name="HorizontalThumb" Grid.Column="1" Height="{TemplateBinding Height}" IsTabStop="False" Template="{StaticResource SliderThumb}" Width="{TemplateBinding Height}" /> <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.Column="2" Template="{x:Null}" /> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Determinate" /> <VisualState x:Name="Indeterminate"> <Storyboard RepeatBehavior="Forever"> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="IndeterminateRoot"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility> Visible </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeterminateRoot"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility> Collapsed </Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ProgressBarTrack"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="0" /> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Duration="00:00:02.9" Storyboard.TargetProperty="value" Storyboard.TargetName="slider1"> <LinearDoubleKeyFrame KeyTime="00:00:00.4" Value="1000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.4" Value="2000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.8" Value="3000" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Duration="00:00:02.9" Storyboard.TargetProperty="value" Storyboard.TargetName="slider2"> <LinearDoubleKeyFrame KeyTime="00:00:00.4" Value="1000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.4" Value="2000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.8" Value="3000" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Duration="00:00:02.9" Storyboard.TargetProperty="value" Storyboard.TargetName="slider3"> <LinearDoubleKeyFrame KeyTime="00:00:00.4" Value="1000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.4" Value="2000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.8" Value="3000" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Duration="00:00:02.9" Storyboard.TargetProperty="value" Storyboard.TargetName="slider4"> <LinearDoubleKeyFrame KeyTime="00:00:00.4" Value="1000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.4" Value="2000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.8" Value="3000" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Duration="00:00:02.9" Storyboard.TargetProperty="value" Storyboard.TargetName="slider5"> <LinearDoubleKeyFrame KeyTime="00:00:00.4" Value="1000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.4" Value="2000" /> <LinearDoubleKeyFrame KeyTime="00:00:02.8" Value="3000" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Duration="00:00:02.9" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="slider1"> <DiscreteDoubleKeyFrame KeyTime="00:00:02.8" Value="0" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Duration="00:00:02.9" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="slider2"> <DiscreteDoubleKeyFrame KeyTime="00:00:02.8" Value="0" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Duration="00:00:02.9" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="slider3"> <DiscreteDoubleKeyFrame KeyTime="00:00:02.8" Value="0" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Duration="00:00:02.9" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="slider4"> <DiscreteDoubleKeyFrame KeyTime="00:00:02.8" Value="0" /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Duration="00:00:02.9" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="slider5"> <DiscreteDoubleKeyFrame KeyTime="00:00:02.8" Value="0" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="ProgressBarTrack" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Opacity="0.3" Background="Black" /> <Grid x:Name="ProgressBarRootGrid"> <Grid x:Name="IndeterminateRoot" Visibility="Collapsed"> <Slider x:Name="slider1" Height="{TemplateBinding Height}" Style="{StaticResource PhoneProgressBarSliderStyle}" /> <Slider x:Name="slider2" Height="{TemplateBinding Height}" Style="{StaticResource PhoneProgressBarSliderStyle}" /> <Slider x:Name="slider3" Height="{TemplateBinding Height}" Style="{StaticResource PhoneProgressBarSliderStyle}" /> <Slider x:Name="slider4" Height="{TemplateBinding Height}" Style="{StaticResource PhoneProgressBarSliderStyle}" /> <Slider x:Name="slider5" Height="{TemplateBinding Height}" Style="{StaticResource PhoneProgressBarSliderStyle}" /> </Grid> <Grid x:Name="DeterminateRoot" Visibility="Visible"> <Border x:Name="ProgressBarIndicator" HorizontalAlignment="Left" d:IsHidden="True" Background="#FFDC2100" BorderBrush="White" BorderThickness="0,0,0,0" /> </Grid> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="PhoneButtonStylePause" TargetType="Button"> <Setter Property="Background" Value="{StaticResource TransparentBrush}" /> <Setter Property="BorderBrush" Value="{StaticResource PhoneAccentBrush}" /> <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" /> <Setter Property="MinHeight" Value="72" /> <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}" /> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}" /> <Setter Property="Padding" Value="10,0,10,5" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid Background="Transparent"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver" /> <VisualState x:Name="Pressed"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Foreground" Storyboard.TargetName="foregroundContainer"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Border.Background" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Border.BorderBrush" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Shape.Fill" Storyboard.TargetName="PauseIcon"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFFFFFFF" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Foreground" Storyboard.TargetName="foregroundContainer"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.BorderBrush" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Background" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="FocusStates"> <VisualState x:Name="Focused" /> <VisualState x:Name="Unfocused" /> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="ButtonBackground" BorderThickness="3" Background="#00FFFFFF" CornerRadius="50" Margin="23,3" BorderBrush="White"> <Grid> <ContentControl x:Name="foregroundContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" /> <Path x:Name="PauseIcon" Data="M71.999985,1.5020368E-05 L111.99998,1.5020368E-05 L111.99998,75.000008 L71.999985,75.000008 z M0,0 L40,0 L40,75 L0,75 z" Fill="#FFFFFFFF" Stretch="Fill" UseLayoutRounding="False" RenderTransformOrigin="0.5,0.5" Margin="0,10.556"> <Path.RenderTransform> <CompositeTransform ScaleX="0.35" ScaleY="0.6" /> </Path.RenderTransform> </Path> </Grid> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="PhoneButtonStylePlay" TargetType="Button"> <Setter Property="Background" Value="{StaticResource TransparentBrush}" /> <Setter Property="BorderBrush" Value="{StaticResource PhoneAccentBrush}" /> <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" /> <Setter Property="MinHeight" Value="72" /> <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}" /> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}" /> <Setter Property="Padding" Value="10,0,10,5" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid Background="Transparent"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver" /> <VisualState x:Name="Pressed"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Foreground" Storyboard.TargetName="foregroundContainer"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Border.Background" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Border.BorderBrush" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFDC2100" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Shape.Fill" Storyboard.TargetName="PlayIcon"> <DiscreteObjectKeyFrame KeyTime="0" Value="#FFFFFFFF" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Foreground" Storyboard.TargetName="foregroundContainer"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.BorderBrush" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Control.Background" Storyboard.TargetName="ButtonBackground"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="FocusStates"> <VisualState x:Name="Focused" /> <VisualState x:Name="Unfocused" /> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="ButtonBackground" BorderThickness="3" Background="#00FFFFFF" CornerRadius="50" Margin="23,3" BorderBrush="White"> <Grid> <ContentControl x:Name="foregroundContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" /> <Path x:Name="PlayIcon" Stretch="Fill" Data="F1 M26.6633,15.998 C17.775534,21.330667 0,31.996 0,31.996 C0,31.996 0,1.52588E-05 0,1.52588E-05 C0,1.52588E-05 17.775534,10.665339 26.6633,15.998 z" UseLayoutRounding="False" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Height="59.154" Fill="White" Margin="5.25,0,-5.25,0"> <Path.RenderTransform> <CompositeTransform ScaleX="0.4" ScaleY="0.65" TranslateX="-1.7881393432617188E-07" TranslateY="-2.384185791015625E-07" /> </Path.RenderTransform> </Path> </Grid> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
搞定
转载请注明文章出处:http://www.cnblogs.com/thinkaspx/