【问题标题】:Transparent busy indicator透明忙碌指示灯
【发布时间】: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


【解决方案1】:

答案将是样式化或更改模板。 Here 是一个问题,其答案显示更改了该控件的模板和样式。

当然,魔鬼在细节中……你需要做一些研究来具体找出控件的结构是什么,找出你想要的样式。如果你还没有做过这种事情,我应该管理你的期望,可能需要一点时间来弄清楚你需要做什么。

【讨论】:

  • 另一个线程中的答案是另一个问题。这并没有回答如何使 BusyIndi​​cator 透明的问题。仅设置 BusyContentTemplate - 即使背景颜色为透明也不会使 BusyIndi​​cator 透明。
猜你喜欢
  • 1970-01-01
  • 2012-07-28
  • 2012-01-20
  • 2011-09-24
  • 2013-06-25
  • 1970-01-01
  • 2017-05-25
  • 2018-11-04
  • 1970-01-01
相关资源
最近更新 更多