在WPF按钮显示点 - 点 - 点进步 [英] Display dot-dot-dot progress in a WPF button

查看:139
本文介绍了在WPF按钮显示点 - 点 - 点进步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现用来表示在进度条和轮然而使用进度相当多的例子;我能找到的只有一个JavaScript的例子来说明一个省略号(点 - 点 - 点)指的进步,因此我觉得问这个问题的。我的应用程序是不是很复杂 - 它只有几个检查框和一个按钮。最近我的团队要求提供的增强,并希望保持它很简单。

I found quite a few examples for showing progress where the progress bars and wheels are used however; I could find only one javascript example to show an ellipsis (dot-dot-dot) to refer progress hence I thought of asking this question. My app is not very complex - it only has a few check-boxes and one button. Recently my team requested for an enhancement and want to keep it simple as well.

有一个名为GO用户配置所需的设置后,点击按钮。其背后的code也确实简单 - 它的单击事件后关闭按钮,呼叫是使用一个独立的EXE 的ProcessStartInfo 执行三项行动reconcle,岗位和发布。我用的是 WaitForExist()的方法来重新启用按钮。

There is a button named 'GO' that the user clicks after configuring the required settings. The code behind it is also really straightforward - it disables the button after the click event and call's a standalone exe using ProcessStartInfo that performs three actions 'reconcle', 'post' and 'publish'. I use the WaitForExist() method to re-enable the button.

我的要求我的团队,以显示在按钮上的当前进程。他们只是想在按钮上的文字显示调和。核对..核对...(定期说,1秒),随后以类似的方式发布和出版

I was requested by my team to show the 'current process' on the button. They simply want the button text to show Reconciling. Reconciling.. Reconciling... (at regular intervals say, 1 sec) followed by Posting and Publishing in a similar fashion.

这将是很好知道最合适的方式来实现这一目标。先谢谢了。

It would be nice to know the most appropriate way to achieve this. Thanks in advance.

推荐答案

这样做的最简单的方法是使用 ObjectAnimationUsingKeyFrames 。设置TargetProperty上的内容,并设置每个 DiscreteObjectKeyFrame 调和。调和调和... ...

The simplest way of doing that is using an ObjectAnimationUsingKeyFrames. Set the TargetProperty on the Content and set the Value of each DiscreteObjectKeyFrame to Reconciling. Reconciling.. Reconciling....

例如用于控件模板内容presenter 名为 PART_Content

<ControlTemplate.Triggers>
    <Trigger Property="IsEnabled" Value="False">
        <Trigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Content" Duration="00:00:00.8" RepeatBehavior="Forever">
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.0" Value="Loading"/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.2" Value="Loading."/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.4" Value="Loading.."/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.6" Value="Loading..."/>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </Trigger.EnterActions>
    </Trigger>
</ControlTemplate.Triggers>

这篇关于在WPF按钮显示点 - 点 - 点进步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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