Skip to content

Instantly share code, notes, and snippets.

@damirarh
Created May 5, 2013 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damirarh/5520235 to your computer and use it in GitHub Desktop.
Save damirarh/5520235 to your computer and use it in GitHub Desktop.
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<ProgressBar Value="{Binding Progress}"
Minimum="0"
Maximum="1"
Visibility="{Binding Initialized, Converter={StaticResource InvertedBoolToVisibilityConverter}}"/>
<TextBlock Text="{Binding Text}"
TextWrapping="Wrap"
Visibility="{Binding Initialized, Converter={StaticResource BoolToVisibilityConverter}}"
Style="{StaticResource BasicTextStyle}" />
</Grid>
public ViewModel()
{
var progress = new Progress<double>();
progress.ProgressChanged += (s, v) => Progress = v;
Init(progress);
}
private async void Init(IProgress<double> progress)
{
var file = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Text.txt");
Text = await FileIO.ReadTextAsync(file);
for (int i = 0; i < 10; i++)
{
await Task.Delay(500);
progress.Report((double)i/10);
}
Initialized = true;
}
public string Text
{
get { return _text; }
set
{
if (value == _text) return;
_text = value;
OnPropertyChanged();
}
}
public double Progress
{
get { return _progress; }
set
{
if (value.Equals(_progress)) return;
_progress = value;
OnPropertyChanged();
}
}
public bool Initialized
{
get { return _initialized; }
set
{
if (value.Equals(_initialized)) return;
_initialized = value;
OnPropertyChanged();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment