与IsIndeterminate试图把一个进度XAML模板问题 [英] Problem with IsIndeterminate while trying to put together a ProgressBar XAML template

查看:204
本文介绍了与IsIndeterminate试图把一个进度XAML模板问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm创造了WPF 进度 A XAML模板。下面的XAML code工作正常,如果 IsIndeterminate 设置为

I´m creating a XAML template for the WPF ProgressBar. The following XAML code works fine if IsIndeterminate is set to False:

<ControlTemplate x:Key="DefaultProgressBarTemplate" TargetType="{x:Type ProgressBar}">
    <ControlTemplate.Resources>
        <SolidColorBrush x:Key="SolidBorderBrush" Color="#767676" />
        <LinearGradientBrush x:Key="IndicatorBrush" StartPoint="0,0" EndPoint="1,0">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#BCCF64" Offset="0.5" />
                <GradientStop Color="#E1FF77" Offset="0.0" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </ControlTemplate.Resources>
    <Grid MinHeight="14">
        <Border Name="PART_Track" CornerRadius="9" Background="Transparent" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" />
        <Border Name="PART_Indicator" CornerRadius="9" Background="{StaticResource IndicatorBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1" HorizontalAlignment="Left" SnapsToDevicePixels="True" />
    </Grid>
</ControlTemplate>

<Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="Template" Value="{StaticResource DefaultProgressBarTemplate}" />
</Style>

该指标边境填补了进度从最小到最大。但是,如果我设置 IsIndeterminate 指示灯边框填满整个进度(像它被设置为最大值),并没有什么动画的。没有什么我试图做修改进度的这种行为。 什么我必须做有一个 IsIndeterminate 动画类似于一个在标准WPF 进度

The indicator border fills up the ProgressBar from min to max. But if I set IsIndeterminate to True the indicator border fills up the entire ProgressBar (like it is set to max) and nothing is animated at all. Nothing I tried did change this behaviour of the ProgressBar. What do I have to do to have an IsIndeterminate animation similar to the one in the standard WPF ProgressBar?

在此先感谢

万岁

推荐答案

进度旨在显示整个指标时, IsIndeterminate =真 。 WPF的内置进度风格实际上代替指示灯的颜色与动画刷,只要 IsIndeterminate =真正的造成影响你观察。你可以这样做。只要使用在 IsIndeterminate =属性触发器真正的,并设置画笔画笔的颜色要为其制作动画。另一种选择是创建由 IsIndeterminate =真正的触发一个单独的动画,如果你想要一个不同的效果。

ProgressBar is designed to show the entire indicator when IsIndeterminate="true". WPF's built in ProgressBar styles actually replace the indicator color with an animated brush whenever IsIndeterminate="true" to cause the effect you are observing. You could do the same. Just use a property trigger on IsIndeterminate="true" and set the brush to a brush whose colors you are animating. Another option would be to create a separate animation triggered by IsIndeterminate="true" if you wanted a different effect.

您可以看一下对内置样式使用NET的反射工具连同其BamlViewer加载项。原来的源文件也被复制到硬盘上安装了防爆pression混合时,即使是试用版,所以安装前pression Blend是另一种方式来看到XAML的内置样式。只要看看在 C:\ Program Files文件\微软前pression \混合2 \ SystemThemes 目录

You can look at the built-in styles by using the NET Reflector tool along with its BamlViewer add-in. The original source files are also copied onto your hard disk when Expression Blend is installed, even the evaluation version, so installing Expression Blend is another way to see the XAML for the built-in styles. Just look in the C:\Program Files\Microsoft Expression\Blend 2\SystemThemes directory.

这篇关于与IsIndeterminate试图把一个进度XAML模板问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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