0
我得到了以下ProgressBar
風格:IsIndeterminate進度模板
<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>
如果我設置IsIndeterminate
到True
上ProgressBar
;我可以看到Indicator
在designer
移動,但不在runtime
。任何人都知道爲什麼它不起作用runtime
?
編輯:
使用Visual Studio 2012專業版/應用程序是WPF .NET 3.5
在'resourcedictionary'中只有'progressbar'和這個樣式的''window''。窗戶不凍結。奇怪的是;它在設計師工作。 – majk86
嗯,這個愚蠢的問題:你有IsIntermediate屬性設置爲true? :)它沒有風格的工作嗎? –
是啊:) ofc它的設置。就像我說的;它在'designer'中工作,但不在'runtime'上。試用了'resourcedictionary'的移動風格。嘗試用'trigger'替換'VSM'。默認'progressbar'沒有'style'正在工作。 – majk86