消息框的 Silverlight BusyIndi​​cator 背景颜色 [英] Silverlight BusyIndicator background color for the message box

查看:22
本文介绍了消息框的 Silverlight BusyIndi​​cator 背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Silverlight 中,我需要 BusyIndi​​cator 的消息框是透明的.我发现了一个问题,但没有任何解决方案:

In Silverlight, I need the message box of a BusyIndicator to be transparent. I found a question asking the same but without any solution:

Silverlight BusyIndi​​cator 背景色

我的部分代码如下:

<toolkit:BusyIndicator x:Name="WorkingLayout" Height="80">
        <toolkit:BusyIndicator.BusyContent>
            <StackPanel>
                <TextBlock Text="Wait please..." HorizontalAlignment="Center"></TextBlock>
                <Button x:Name="CancelButton" HorizontalAlignment="Center" Content="Cancel" Width="100" Click="CancelButton_Click" />
            </StackPanel>
        </toolkit:BusyIndicator.BusyContent>
        <!-- Rest of component code -->
</toolkit:BusyIndicator>

有没有办法让所有内容背景都透明,包括包含消息的框,而不是默认的灰色渐变?

Is there a way to make all the content background transparent, including the box containing the message, not in grey gradient as it comes as default?

我尝试将属性背景设置为透明:

I tried to set the property Background to transparent like that:

<toolkit:BusyIndicator x:Name="WorkingLayout" Height="80" Background="Transparent">

但是没有用.

推荐答案

你可以得到你想要的,你只需要编辑模板来满足你的需要.在表情混合中,

You can get what you want, you just have to edit the template to suit your needs. In expression blend,

  1. 右键单击忙指示符,选择编辑模板,编辑副本
  2. 在模板里面,找到进度条,删除
  3. 如果要删除灰色框,请将内容演示器向上移动到更高的网格,并删除边框对象这是我制作的一个忙碌指标示例,

  1. Right click the busy indicator, select edit template, edit a copy
  2. Inside the template, find the progress bar, and delete it
  3. If you want to remove the gray box, move the Content presenter up to a higher grid, and delete the border objects here is one sample busyindicator i made,

        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:BusyIndicator">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="VisibilityStates">
                               <VisualState x:Name="Hidden">
                                    <Storyboard>
                                      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="busycontent" Storyboard.TargetProperty="(UIElement.Visibility)">
                                           <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                   <Visibility>Collapsed</Visibility>
                                               </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="overlay" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                              <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Visible">
                                    <Storyboard>
                                       <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="busycontent" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                           </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="overlay" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                               </DiscreteObjectKeyFrame.Value>
                                           </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                       <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" RepeatBehavior="Forever">
                                           <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                            <EasingDoubleKeyFrame KeyTime="00:00:01" Value="360"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                           </VisualStateGroup>
                            <VisualStateGroup x:Name="BusyStatusStates">
                                <VisualState x:Name="Idle">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="content" Storyboard.TargetProperty="(Control.IsEnabled)">
                                           <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>True</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Busy">
                                   <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="content" Storyboard.TargetProperty="(Control.IsEnabled)">
                                           <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                               <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>False</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                       </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                              </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl x:Name="content" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <Rectangle x:Name="overlay" Style="{TemplateBinding OverlayStyle}"/>
                        <ContentPresenter x:Name="busycontent">
                            <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Ellipse x:Name="ellipse" Margin="-13,-46,-15,-44" StrokeThickness="15" RenderTransformOrigin="0.5,0.5">
                                    <Ellipse.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform/>
                                            <SkewTransform/>
                                            <RotateTransform/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </Ellipse.RenderTransform>
                                    <Ellipse.Stroke>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                           <GradientStop Color="Black" Offset="0"/>
                                            <GradientStop Color="Transparent" Offset="0.94"/>
                                        </LinearGradientBrush>
                                    </Ellipse.Stroke>
                                </Ellipse>
                                <ContentPresenter Margin="8,8,12,8" Content="{TemplateBinding BusyContent}" ContentTemplate="{TemplateBinding BusyContentTemplate}"/>
                            </Grid>
                        </ContentPresenter>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
    <toolkit:BusyIndicator Background="Transparent" Style="{StaticResource BusyIndicatorStyle1}" BorderThickness="0" x:Name="WorkingLayout" Height="80" Margin="65,110,123,110">
        <!--<toolkit:BusyIndicator.OverlayStyle>
            <Style TargetType="Rectangle">
                <Setter Property="Fill" Value="White"/>
                <Setter Property="Opacity" Value="0.5"/>
            </Style>
        </toolkit:BusyIndicator.OverlayStyle>-->
        <toolkit:BusyIndicator.BusyContent>
            <StackPanel>
                <TextBlock Text="Wait please..." HorizontalAlignment="Center"></TextBlock>
                <Button x:Name="CancelButton" HorizontalAlignment="Center" Content="Cancel" Width="100"  />
            </StackPanel>
        </toolkit:BusyIndicator.BusyContent>
        <!-- Rest of component code -->
    </toolkit:BusyIndicator>


</Grid>

这篇关于消息框的 Silverlight BusyIndi​​cator 背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆