ProgressBarWithText.xaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <UserControl x:Class="WindowsPhone.Recipes.Push.Client.Controls.ProgressBarWithText"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:localHelpers="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
  7. xmlns:unsupported="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
  8. mc:Ignorable="d"
  9. FontFamily="{StaticResource PhoneFontFamilyNormal}"
  10. FontSize="{StaticResource PhoneFontSizeNormal}"
  11. Foreground="{StaticResource PhoneForegroundBrush}"
  12. d:DesignHeight="480" d:DesignWidth="480"
  13. >
  14. <UserControl.Resources>
  15. <localHelpers:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
  16. <Style x:Key="PerformanceProgressBar" TargetType="ProgressBar">
  17. <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
  18. <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
  19. <Setter Property="Maximum" Value="100"/>
  20. <Setter Property="IsHitTestVisible" Value="False"/>
  21. <Setter Property="Padding" Value="{StaticResource PhoneHorizontalMargin}"/>
  22. <Setter Property="Template">
  23. <Setter.Value>
  24. <ControlTemplate TargetType="ProgressBar">
  25. <unsupported:RelativeAnimatingContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
  26. <unsupported:RelativeAnimatingContentControl.Resources>
  27. <ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseOut"/>
  28. <ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseIn"/>
  29. </unsupported:RelativeAnimatingContentControl.Resources>
  30. <VisualStateManager.VisualStateGroups>
  31. <VisualStateGroup x:Name="CommonStates">
  32. <VisualState x:Name="Determinate"/>
  33. <VisualState x:Name="Indeterminate">
  34. <Storyboard RepeatBehavior="Forever" Duration="00:00:04.4">
  35. <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="IndeterminateRoot">
  36. <DiscreteObjectKeyFrame KeyTime="0">
  37. <DiscreteObjectKeyFrame.Value>
  38. <Visibility>Visible</Visibility>
  39. </DiscreteObjectKeyFrame.Value>
  40. </DiscreteObjectKeyFrame>
  41. </ObjectAnimationUsingKeyFrames>
  42. <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeterminateRoot">
  43. <DiscreteObjectKeyFrame KeyTime="0">
  44. <DiscreteObjectKeyFrame.Value>
  45. <Visibility>Collapsed</Visibility>
  46. </DiscreteObjectKeyFrame.Value>
  47. </DiscreteObjectKeyFrame>
  48. </ObjectAnimationUsingKeyFrames>
  49. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="X" Storyboard.TargetName="R1TT">
  50. <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
  51. <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
  52. <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
  53. <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
  54. </DoubleAnimationUsingKeyFrames>
  55. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="X" Storyboard.TargetName="R2TT">
  56. <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
  57. <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
  58. <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
  59. <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
  60. </DoubleAnimationUsingKeyFrames>
  61. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="X" Storyboard.TargetName="R3TT">
  62. <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
  63. <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
  64. <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
  65. <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
  66. </DoubleAnimationUsingKeyFrames>
  67. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="X" Storyboard.TargetName="R4TT">
  68. <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
  69. <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
  70. <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
  71. <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
  72. </DoubleAnimationUsingKeyFrames>
  73. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="X" Storyboard.TargetName="R5TT">
  74. <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
  75. <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
  76. <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
  77. <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
  78. </DoubleAnimationUsingKeyFrames>
  79. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R1">
  80. <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
  81. <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
  82. </DoubleAnimationUsingKeyFrames>
  83. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R2">
  84. <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
  85. <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
  86. </DoubleAnimationUsingKeyFrames>
  87. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R3">
  88. <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
  89. <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
  90. </DoubleAnimationUsingKeyFrames>
  91. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R4">
  92. <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
  93. <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
  94. </DoubleAnimationUsingKeyFrames>
  95. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R5">
  96. <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
  97. <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
  98. </DoubleAnimationUsingKeyFrames>
  99. </Storyboard>
  100. </VisualState>
  101. </VisualStateGroup>
  102. </VisualStateManager.VisualStateGroups>
  103. <Grid>
  104. <Grid x:Name="DeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Visible">
  105. <Rectangle x:Name="ProgressBarTrack" Fill="{TemplateBinding Background}" Height="4" Opacity="0.1"/>
  106. <Rectangle x:Name="ProgressBarIndicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Height="4"/>
  107. </Grid>
  108. <Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Collapsed">
  109. <Grid HorizontalAlignment="Left">
  110. <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R1" Opacity="0" CacheMode="BitmapCache">
  111. <Rectangle.RenderTransform>
  112. <TranslateTransform x:Name="R1TT"/>
  113. </Rectangle.RenderTransform>
  114. </Rectangle>
  115. <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R2" Opacity="0" CacheMode="BitmapCache">
  116. <Rectangle.RenderTransform>
  117. <TranslateTransform x:Name="R2TT"/>
  118. </Rectangle.RenderTransform>
  119. </Rectangle>
  120. <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R3" Opacity="0" CacheMode="BitmapCache">
  121. <Rectangle.RenderTransform>
  122. <TranslateTransform x:Name="R3TT"/>
  123. </Rectangle.RenderTransform>
  124. </Rectangle>
  125. <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R4" Opacity="0" CacheMode="BitmapCache">
  126. <Rectangle.RenderTransform>
  127. <TranslateTransform x:Name="R4TT"/>
  128. </Rectangle.RenderTransform>
  129. </Rectangle>
  130. <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R5" Opacity="0" CacheMode="BitmapCache">
  131. <Rectangle.RenderTransform>
  132. <TranslateTransform x:Name="R5TT"/>
  133. </Rectangle.RenderTransform>
  134. </Rectangle>
  135. </Grid>
  136. </Border>
  137. </Grid>
  138. </unsupported:RelativeAnimatingContentControl>
  139. </ControlTemplate>
  140. </Setter.Value>
  141. </Setter>
  142. </Style>
  143. </UserControl.Resources>
  144. <StackPanel x:Name="stackPanel"
  145. Visibility="{Binding ShowProgress, Converter={StaticResource booleanToVisibilityConverter}}"
  146. VerticalAlignment="Center"
  147. >
  148. <TextBlock
  149. Text="{Binding Text}"
  150. HorizontalAlignment="Center"
  151. />
  152. <ProgressBar
  153. Foreground="White"
  154. IsIndeterminate="{Binding ShowProgress}"
  155. Style="{StaticResource PerformanceProgressBar}"
  156. Margin="0,5,0,0"
  157. />
  158. </StackPanel>
  159. </UserControl>