Created
May 5, 2013 08:55
-
-
Save damirarh/5520196 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
public class BooleanToVisibilityConverter : IValueConverter | |
{ | |
public bool Inverted { get; set; } | |
public object Convert(object value, Type targetType, object parameter, string language) | |
{ | |
if (!(value is bool)) | |
{ | |
return Visibility.Collapsed; | |
} | |
return (bool)value ^ Inverted ? Visibility.Visible : Visibility.Collapsed; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, string language) | |
{ | |
throw new NotImplementedException(); | |
} | |
} |
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
<Page.Resources> | |
<local:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" /> | |
<local:BooleanToVisibilityConverter x:Key="InvertedBoolToVisibilityConverter" Inverted="True" /> | |
</Page.Resources> | |
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> | |
<ProgressRing IsActive="True" | |
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() | |
{ | |
Init(); | |
} | |
private async void Init() | |
{ | |
var file = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Text.txt"); | |
Text = await FileIO.ReadTextAsync(file); | |
await Task.Delay(2000); | |
Initialized = true; | |
} | |
public string Text | |
{ | |
get { return _text; } | |
set | |
{ | |
if (value == _text) return; | |
_text = 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