Created
May 5, 2013 09:10
-
-
Save damirarh/5520235 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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