【发布时间】:2017-04-08 14:26:34
【问题描述】:
我正在使用 wpftoolkit 库中的繁忙指示器。这是我的代码:
<Window x:Class="BusyControl.MainWindow"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<xctk:BusyIndicator Name="ProgressIndicator" IsBusy="False" Background="Transparent" BorderBrush="Transparent" BorderThickness="0">
<xctk:BusyIndicator.BusyContentTemplate>
<DataTemplate>
<StackPanel>
<Image gif:ImageBehavior.AnimatedSource="Resources/loading.gif" Width="150" Height="50" />
<TextBlock Text="{Binding ElementName=ProgressIndicator, Path=BusyContent}" HorizontalAlignment="Center" Margin="3"></TextBlock>
</StackPanel>
</DataTemplate>
</xctk:BusyIndicator.BusyContentTemplate>
<xctk:BusyIndicator.ProgressBarStyle>
<Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</xctk:BusyIndicator.ProgressBarStyle>
<Grid>
<Button Content="Click me" Click="ButtonBase_OnClick" Width="100" Height="50"></Button>
</Grid>
</xctk:BusyIndicator>
</Grid>
</Window>
但我的忙碌指示器看起来像
但我需要像这样的透明忙碌指示器
我该怎么做?
【问题讨论】:
-
第一个的问题是背景的颜色掩盖了一些灰色。第一张图片中的任何内容都表明它不透明。
-
在 wpftoolkit 库的来源中,我看到 ContentPresenter 的父元素是一个灰色背景的边框。除了源更改之外,还有什么方法可以更改此边框的背景?
-
好的,我在这篇帖子there 中找到了解决方案。我可以使用自己的风格
标签: c# wpf busyindicator