2016-11-24 123 views
1

我正在使用来自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> 

但我的忙指示灯看起来像

before

,但我需要透明的忙指示这样

After

我怎么能这样做?

+0

第一个问题是某些灰色被背景的颜色所掩盖。第一张照片中没有任何内容表明它不是透明的。 – BugFinder

+0

在wpftoolkit库的源代码中,我看到ContentPresenter的父元素是一个灰色背景的边框。有什么方法可以改变这个边界的背景,除了源代码更改吗? – user2455111

+0

好的,我在这篇文章中发现了解决方案[there](http://stackoverflow.com/questions/18984371/silvelight-busyindicator-background-color-for-the-message-box)。我可以使用我自己的风格 – user2455111

回答

2

答案将是造型或更改模板。 Here是带有显示更改该控件的模板和样式的答案的问题。

当然,魔鬼是在细节...你需要做一些研究,找出控制结构的具体内容,找出你想如何设计它。如果你还没有做过这样的事情,我应该管理你的期望,即可能需要一点时间来确定你需要做什么。