Ejemplo n.º 1
0
        private static SourceValueConverter GetSourceValueConverter()
        {
            var sourceValueConverter = new SourceValueConverter();

            sourceValueConverter.Add(typeof(Thickness), context => new ThicknessConverter().ConvertFrom(null, CultureInfo.CurrentCulture, context.Value));
            sourceValueConverter.Add(typeof(Brush), context => new BrushConverter().ConvertFrom(null, CultureInfo.CurrentCulture, context.Value));
            sourceValueConverter.Add(typeof(GridLength), context => new GridLengthConverter().ConvertFrom(null, CultureInfo.CurrentCulture, context.Value));
            sourceValueConverter.Add(typeof(ImageSource), context => new BitmapImage(new Uri((string)context.Value, UriKind.Relative)));
            return(sourceValueConverter);
        }
Ejemplo n.º 2
0
        public static ISourceValueConverter GetSourceValueConverter()
        {
            var sourceValueConverter = new SourceValueConverter();

            sourceValueConverter.Add(typeof(Thickness), value => ConvertToThickness((string)value.Value));
            sourceValueConverter.Add(typeof(Brush), value => ConvertToSolidBrush((string)value.Value));
            sourceValueConverter.Add(typeof(GridLength), value => GetGridLength((string)value.Value));
            sourceValueConverter.Add(typeof(ImageSource), value => ConvertToBitmap((string)value.Value));
            sourceValueConverter.Add(typeof(bool), value => bool.Parse((string)value.Value));
            sourceValueConverter.Add(typeof(FontFamily), value => new FontFamily((string)value.Value));
            return(sourceValueConverter);
        }