大佬教程收集整理的这篇文章主要介绍了xaml – WP7中更厚的ProgressBar,怎么样?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的问题是:如何让进度条变粗?线本身太小,我的应用程序的“主要吸引力”是进度条,我想让它更大.我是否要制作模板并使用其他控件? (就像在视觉上使用矩形).我尝试将进度条更改为矩形,但我不知道如何填充矩形的60%(例如).
有任何想法吗?谢谢!
在默认进度条的样式中,您需要
>为ProgressBar样式添加高度,
说30.
>增加两个矩形的高度
ProgressBarTrack和
ProgressBarInDicator到24.他们是
在ProgressBar的ControlTemplate中.
>增加高度
HorizontalThumb到24.它在里面@H_667_18@phoneProgressBarSliderStyle.
>在PhoneProgressBarSliderThumb中
ConttrolTemplate,增加两者
矩形的宽度和高度为24.
以下是所有样式以防万一.:)
<ControlTemplate x:Key="PhoneProgressBarSliderThumb" TargetType="Thumb"> <Rectangle Fill="{TemplateBinding ForegrounD}" Height="24" IsHitTestVisible="false" Width="24"/> </ControlTemplate> <Style x:Key="PhoneProgressBarSliderStyle" TargetType="Slider"> <Setter Property="Maximum" Value="3000"/> <Setter Property="Minimum" Value="0"/> <Setter Property="Value" Value="0"/> <Setter Property="Opacity" Value="0"/> <Setter Property="IsTabStop" Value="false"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Slider"> <Grid IsHitTestVisible="false"> <Grid x:Name="HorizontalTemplate"> <Grid.columnDeFinitions> <columnDeFinition Width="Auto"/> <columnDeFinition Width="Auto"/> <columnDeFinition Width="*"/> </Grid.columnDeFinitions> <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.column="0" Height="0" Template="{x:Null}"/> <Thumb x:Name="HorizontalThumb" Grid.column="1" Foreground="{TemplateBinding ForegrounD}" Height="24" IsTabStop="false" Template="{Staticresource PhoneProgressBarSliderThumb}"/> <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.column="2" Height="0" Template="{x:Null}"/> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="ProgressBarStyle1" TargetType="ProgressBar"> <Setter Property="Height" Value="30"/> <Setter Property="Foreground" Value="{Staticresource PhoneAccentBrush}"/> <Setter Property="BACkground" Value="{Staticresource PhoneAccentBrush}"/> <Setter Property="Maximum" Value="100"/> <Setter Property="IsHitTestVisible" Value="false"/> <Setter Property="Padding" Value="{Staticresource PhoneHorizontalMargin}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ProgressBar"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Determinate"/> <VisualState x:Name="Indeterminate"> <Storyboard Duration="00:00:04.4" 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> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider1"> <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaSEOut" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/> <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaseIn" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider2"> <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaSEOut" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/> <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaseIn" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider3"> <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaSEOut" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/> <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaseIn" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider4"> <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaSEOut" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/> <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaseIn" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider5"> <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaSEOut" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/> <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000"> <EasingDoubleKeyFrame.EasingFunction> <ExponentialEase EasingMode="EaseIn" Exponent="1"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider1"> <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/> <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider2"> <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/> <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider3"> <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/> <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider4"> <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/> <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider5"> <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/> <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid x:Name="DeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Visible"> <Rectangle x:Name="ProgressBarTrack" Fill="{TemplateBinding BACkgrounD}" Height="24" Opacity="0.1"/> <Rectangle x:Name="ProgressBarInDicator" Fill="{TemplateBinding ForegrounD}" HorizontalAlignment="Left" Height="24"/> </Grid> <Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Collapsed"> <Grid> <Slider x:Name="Slider1" Foreground="{TemplateBinding ForegrounD}" Style="{Staticresource PhoneProgressBarSliderStylE}"/> <Slider x:Name="Slider2" Foreground="{TemplateBinding ForegrounD}" Style="{Staticresource PhoneProgressBarSliderStylE}"/> <Slider x:Name="Slider3" Foreground="{TemplateBinding ForegrounD}" Style="{Staticresource PhoneProgressBarSliderStylE}"/> <Slider x:Name="Slider4" Foreground="{TemplateBinding ForegrounD}" Style="{Staticresource PhoneProgressBarSliderStylE}"/> <Slider x:Name="Slider5" Foreground="{TemplateBinding ForegrounD}" Style="{Staticresource PhoneProgressBarSliderStylE}"/> </Grid> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
以上是大佬教程为你收集整理的xaml – WP7中更厚的ProgressBar,怎么样?全部内容,希望文章能够帮你解决xaml – WP7中更厚的ProgressBar,怎么样?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。