Wpf IsIndeterminate进度条模板
我得到了以下Wpf IsIndeterminate进度条模板,wpf,xaml,progress-bar,Wpf,Xaml,Progress Bar,我得到了以下ProgressBar样式: <Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}"> <Setter Property="Background" Value="{StaticResource ControlBackground}" /> <Setter Property="BorderBrush" Value="{StaticResource Activ
ProgressBar
样式:
<Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
<Setter Property="Background" Value="{StaticResource ControlBackground}" />
<Setter Property="BorderBrush" Value="{StaticResource ActiveControlBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="MinHeight" Value="23" />
<Setter Property="MinWidth" Value="75" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid MinHeight="{TemplateBinding MinHeight}"
MinWidth="{TemplateBinding MinWidth}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate" />
<VisualState x:Name="Indeterminate">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="00:00:00"
Storyboard.TargetName="PART_Indicator"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="00:00:00">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush>Transparent</SolidColorBrush>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="PART_Track"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<Border x:Name="PART_Indicator"
Background="{TemplateBinding BorderBrush}"
HorizontalAlignment="Left" />
<Grid x:Name="Animation" ClipToBounds="True">
<Border x:Name="PART_GlowRect"
Width="100"
Background="{StaticResource ActiveControlBorderBrush}"
HorizontalAlignment="Left"
Margin="-100,0,0,0" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
透明的
如果我在ProgressBar
上将isindestime
设置为True
;我可以看到指示器
在设计器
中移动,但不能在运行时
上移动。有人知道它为什么不能在运行时运行吗
编辑:
使用Visual Studio Professional 2012/应用程序是WPF.NET 3.5我尝试了您的示例,它似乎很有效。检查:
空的
窗口
,只有进度条
和资源字典中的此样式
。窗户没有结冰。奇怪的是;它在designer中工作。好吧,一个愚蠢的问题:是否将IsIntermediate属性设置为true?:)没有这种风格行得通吗?是的:)ofc已经定了。正如我所说;它在设计器
中工作,但在运行时
中不工作。已尝试将样式移出资源字典
。尝试将VSM
替换为触发器
。没有样式的默认progressbar
正在工作。这很奇怪,因为我看到它在为我工作。我在WPF 4.0中使用了VS 2012,您可以尝试使用不同的.NET版本检查此问题。