Last active
August 29, 2015 14:20
-
-
Save idiotandrobot/101c1631fc96cf181c4f to your computer and use it in GitHub Desktop.
Windows Phone 8.1 StringFormatConverter
This file contains 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 sealed class StringFormatConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, string language) | |
{ | |
if (value == null) | |
return null; | |
if (parameter == null) | |
return value; | |
return string.Format((string)parameter, value); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, | |
string language) | |
{ | |
throw new NotImplementedException(); | |
} | |
} |
This file contains 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
<StringFormatConverter x:Name="StringFormat"/> | |
<TextBlock Text="{Binding DateTime, StringFormat=T, RelativeSource={RelativeSource TemplatedParent}}" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment