.
using Windows.UI;
using Windows.UI.Xaml.Media;
public class ColorResolver : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return GetColorFromHexa((string) value));
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
private SolidColorBrush GetColorFromHexa(string hexaColor)
{
return new SolidColorBrush(
Color.FromArgb(
255,
Convert.ToByte(hexaColor.Substring(1, 2), 16),
Convert.ToByte(hexaColor.Substring(3, 2), 16),
Convert.ToByte(hexaColor.Substring(5, 2), 16)
)
);
}
}
, .
<Border Background="{Binding MyColorProperty, Converter={StaticResource MyColorConverter}}" Margin="6" toolkit:TiltEffect.IsTiltEnabled="True">
<TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Margin="12,0,0,0" Foreground="White" VerticalAlignment="Bottom"/>
</Border>
WinRT. GetColorFromHexa() WP8 . . . !:)