全部,
我是 Xamarin 的新手,更值得注意的是,C# 所以请善待......!
我有一个 Xamarin.Forms 应用程序,它使用 DependencyService 下降到 .iOS,然后遍历我设备上的所有歌曲并使用自定义“歌曲”模型返回。
毫无疑问,有更好的方法可以做到这一点,但为了将专辑插图返回到 PCL,我将 iOS UIImage 转换为 System.IO.Stream 对象,然后通过 Song 模型返回它。
添加此艺术作品功能会在处理每首歌曲时产生更大的开销。为了尝试让用户了解正在发生的事情,我在页面上放置了一个进度条,并希望它在我每次处理一首歌曲时更新。
我的问题是,我一直无法让进度条实时更新。它仅在该过程完成后更新。
在这个阶段我没有使用 MVVM,所以这是背后的代码......
using Xamarin.Forms;
using TestApplication.Interfaces;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System;
namespace TestApplication
{
public partial class TestApplicationPage : ContentPage, INotifyPropertyChanged
{
private double _progress;
public double Progress
{
get { return _progress; }
set
{
_progress = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
public TestApplication()
{
InitializeComponent();
BindingContext = this;
}
private …Run Code Online (Sandbox Code Playgroud)