wpf 扩展工具包有一个 BusyIndicator 控件,并且可以将模板应用于该控件中包含的进度条。我希望进度条像 win 8 中的环形进度条(如代码项目http://www.codeproject.com/Articles/700185/Windows-Progress-Ring中的此处)但我不能应用控件,只是一个DataTemplate。有任何想法吗?
问问题
2534 次
1 回答
2
BusyIndicator 被设计为内容控件。这意味着它会包装您放入的内容并为其添加广告。你可以为它创建一个 ControlTemplate 但你必须使它像这样:
<Style TargetType="{x:Type xctk:BusyIndicator}" x:Key="ProgressRing">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:BusyIndicator}">
<Grid>
<ContentControl Content="{TemplateBinding Content}"></ContentControl>
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
x:Name="Overlay" Visibility="{TemplateBinding IsBusy, Converter={StaticResource BoolToVis}}">
<Border.Background>
<SolidColorBrush Color="Black" Opacity="0.5"></SolidColorBrush>
</Border.Background>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">progress</TextBlock>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
这类似于 BusyIndicator 的构建方式,但允许您替换它使用的进度条。只需更换
顺便说一句,对于进度环,您可以使用 imageview 并简单地围绕它无限旋转它。
于 2014-05-26T08:39:45.280 回答