向视图框添加效果时,对象显示为灰色

时间:2013-12-26 13:05:33

标签: wpf xaml

我在Viewbox中添加了一个效果,如下所示:

<Viewbox Height="40" Width="40" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,12.5,65,0" >
    <Viewbox.Effect>
        <effects:RippleEffect Magnitude="0" Frequency="0" />
    </Viewbox.Effect>
    <Grid>
        <Rectangle x:Name="MinimizeRect" RadiusX="7" RadiusY="7" StrokeThickness="2" Stroke="White" Fill="Transparent"/>
        <Image Source="Images/Minimize.png" Margin="5"/>
    </Grid>
    <Viewbox.Triggers>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" >
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(Effect).Magnitude" To="0.1" Duration="0:0:0.3" AutoReverse="True" RepeatBehavior="Forever" />
                    <DoubleAnimation Storyboard.TargetProperty="(Effect).Frequency" To="40" Duration="0:0:0.3" AutoReverse="True" RepeatBehavior="Forever"/>
                    <ColorAnimation Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" To="DodgerBlue" Duration="0:0:0.3" Storyboard.TargetName="MinimizeRect"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" >
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(Effect).Magnitude" To="0" Duration="0:0:0.3" />
                    <DoubleAnimation Storyboard.TargetProperty="(Effect).Frequency" To="0" Duration="0:0:0.3" />
                    <ColorAnimation Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" To="Transparent" Duration="0:0:0.3" Storyboard.TargetName="MinimizeRect"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Viewbox.Triggers>
</Viewbox>

但我的图像和矩形描边并不是白色。它们是灰色的。这可能是什么问题?

这是图像。

enter image description here

在上图中,Ripple效果被添加到Minimize按钮。任何效果都不会添加到关闭按钮。

1 个答案:

答案 0 :(得分:0)

尝试将RenderOptions.BitmapScalingMode设置为HighQuality,如下所示:

<Image Source="Images/Minimize.png" Margin="5"
       RenderOptions.BitmapScalingMode="HighQuality" />