I have a ProgressBar in my MainPage.xaml:
<ProgressBar HorizontalAlignment="Center"
Height="90" Margin="0,-30,0,0"
VerticalAlignment="Center"
Width="600" x:Name="BarProgress" />
And then in MainPage.xaml.cs there is the code for downloading data:
public async Task Download(string fileName, string fileId)
private async Task HandleDownloadAsync(DownloadOperation download, bool start)
private async Task DiscoverActiveDownloadsAsync()
private void DownloadProgress(DownloadOperation download)
{
double percent = 100;
if (download.Progress.TotalBytesToReceive > 0)
{
percent = download.Progress.BytesReceived * 100 / download.Progress.TotalBytesToReceive;
}
BarProgress.Value = percent;
}
And it works great! I can see the ProgressBar proceeds until the download ends!
But if i want to create a new class such as DownloadData.xaml.cs and then put inside all the code for downloading data, how can i invoke the BarProgress.Value?!? I've done a lot of tentatives, such as MainPage.BarProgress.Value = percent, but i receive a lot of errors because BarProgress is inaccesible...