WP8 - Bind ProgressBar visibility
I have a simple thing to code, i checked other questions but couldn't it yet.
I have an application which loads some data from an xml file retrieved
from the web, and then displays it inside a longlistselector.
I did it, it works, now i would like to add an indeterminate progressbar
which stays active until I finished the data loading.
I enclosed the progressbar in a stackpanel, before my longlistselector,
and i bound its visibility to the function ProgressBarVisibility (see code
below).
<phone:PivotItem Header="Status">
<StackPanel>
<ProgressBar Value ="0" IsIndeterminate="True"
Visibility="{Binding ProgressBarVisibility}"/>
<phone:LongListSelector Margin="0,0,-12,0"
ItemsSource="{Binding PivotOne}">
<phone:LongListSelector.ItemTemplate>
<!-- lots of code here -->
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</StackPanel>
</phone:PivotItem>
In the MainViewModel.cs , that's how i wrote the thing.
using System.Windows;
public Visibility ProgressBarVisibility { get; set; }
public void LoadData()
{
//progressbar is visible, data not loaded
this.IsDataLoaded = false;
ProgressBarVisibility = Visibility.Visible;
// Load Static and dynamic data -- populate the different pivots
LoadStaticData();
LoadXMLFile();
// data loaded, progressbar collapsed
this.IsDataLoaded = true;
ProgressBarVisibility = Visibility.Collapsed;
}
So i included system.windows library, and used the visibility class.
Anyway, i cannot get the progressbar to disappear when the loading is
done, it keeps going.
Any suggestion? where am i doing it wrong?
Thanks in advance!
No comments:
Post a Comment