.net毛伊岛不确定的进度栏

发布于 2025-02-13 09:05:58 字数 629 浏览 3 评论 0原文

我正在使用.NET MAUI构建跨平台桌面应用程序。

我有一个很长的事件,我想展示一个不确定的进度栏(就像看到的在这里),因此用户可以看到该操作在没有已知端的情况下运行。

我熟悉MAUI Progressbar元素以及如何为已知进度动画动画,如在这里

await progressBar.ProgressTo(0.75, 500, Easing.Linear);

但是,似乎没有一种本地方法可以使酒吧生长和缩小,而无需从0-100起动画,然后再返回。当以这种方式进行动画时,我必须填充整个栏,然后将其动画回到0。我无法在范围之间进行动画(例如25%-50%)。

有没有办法在毛伊岛应用程序中实现不确定的进度栏?

I am using .NET MAUI to build a cross platform desktop application.

I have a lengthy event for which I would like to show an indeterminate progress bar (like the one seen here) so the user can see that the operation is running without a known end.

I am familiar with the MAUI progressbar element and how to animate known progress as shown here.

await progressBar.ProgressTo(0.75, 500, Easing.Linear);

However, there doesn't seem to be a native way of growing and shrinking the bar without animating from 0-100 and back again. When animating in this manner, I have to fill the entire bar and animate back to 0. I am not able to animate between a range (25% - 50% for instance).

Is there a way to achieve an indeterminate progress bar in a MAUI app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦与时光遇 2025-02-20 09:05:58

我刚刚在nuget.org上发布了一个progressbar软件包,可用于您的目的。它可以与.NET MAUI桌面应用程序以及移动应用程序一起使用。

https://github.com/ewerspej/ewerspej/epj.progresspej.progressbar.maui

repo : https://www.nuget.org/pack/packages/packages/epj.progressbar.maui

S>仍然是预先发行的,但是如果您喜欢的话,您可以尝试一下。

您将必须根据自己的需求实施动画,但是您绝对可以使用动画来创建不确定状态之类的东西。

XAML

您需要设置userange = true才能工作。

<maui:ProgressBar
    x:Name="AnimatedProgressBar"
    HeightRequest="5"
    Margin="15,0"
    UseRange="True"
    UseGradient="True"
    ProgressColor="Blue"
    GradientColor="Orange"/>

代码

public MainPage()
{
    InitializeComponent();
    BindingContext = this;

    var lowerAnimation = new Animation(v => AnimatedProgressBar.LowerRangeValue = (float)v, -0.4, 1.0);
    var upperAnimation = new Animation(v => AnimatedProgressBar.UpperRangeValue = (float)v, 0.0, 1.4);

    lowerAnimation.Commit(this, "lower", length: 1000, easing: Easing.CubicInOut, repeat: () => true);
    upperAnimation.Commit(this, "upper", length: 1000, easing: Easing.CubicInOut, repeat: () => true);
}

I have just published a ProgressBar package on nuget.org that can be used for your purposes. It works with .NET MAUI Desktop applications as well as mobile apps.

Repo: https://github.com/ewerspej/epj.ProgressBar.Maui

Nuget: https://www.nuget.org/packages/epj.ProgressBar.Maui

It's still a pre-release, but you can try it out, if you like.

You would have to implement the animation according to your own needs, but you can definitely use animations to create something like an indeterminate state.

XAML

You need to set UseRange = true for this to work.

<maui:ProgressBar
    x:Name="AnimatedProgressBar"
    HeightRequest="5"
    Margin="15,0"
    UseRange="True"
    UseGradient="True"
    ProgressColor="Blue"
    GradientColor="Orange"/>

Code

public MainPage()
{
    InitializeComponent();
    BindingContext = this;

    var lowerAnimation = new Animation(v => AnimatedProgressBar.LowerRangeValue = (float)v, -0.4, 1.0);
    var upperAnimation = new Animation(v => AnimatedProgressBar.UpperRangeValue = (float)v, 0.0, 1.4);

    lowerAnimation.Commit(this, "lower", length: 1000, easing: Easing.CubicInOut, repeat: () => true);
    upperAnimation.Commit(this, "upper", length: 1000, easing: Easing.CubicInOut, repeat: () => true);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文