保存图片后进度条可见性

时间:2013-09-09 14:40:51

标签: windows-phone-8 progress-bar

我可以在将图像保存到媒体库时显示进度指示器,但我不知道在保存图片后如何更改IsVisible = false。以下是我用它的代码 -

async void Save_Click(object sender, EventArgs e)
    {
        ProgressIndicator progress = new ProgressIndicator();
        progress.IsVisible = true;
        progress.IsIndeterminate = true;
        progress.Text = "saving image...";

        //Save a copy of the image
        using (MediaLibrary library = new MediaLibrary())
        {
            var imgStream = (await App.CurrPhoto.RawSession.RenderToJpegAsync()).AsStream();
            library.SavePicture(DateTime.UtcNow.Ticks.ToString(), imgStream);
        }

        SystemTray.SetProgressIndicator(this, progress);
    }

1 个答案:

答案 0 :(得分:3)

在执行操作之前设置ProgressIndicator,然后在保存代码后将其禁用。

ProgressIndicator progress = new ProgressIndicator();
progress.IsVisible = true;
progress.IsIndeterminate = true;
progress.Text = "saving image...";

//set the indicator before the save code
SystemTray.SetProgressIndicator(this, progress);

//Save a copy of the image
using (MediaLibrary library = new MediaLibrary())
{
   var imgStream = (await App.CurrPhoto.RawSession.RenderToJpegAsync()).AsStream();
   library.SavePicture(DateTime.UtcNow.Ticks.ToString(), imgStream);
}

//disable it
SystemTray.SetProgressIndicator(this, null);