summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP/NativeValueConverterService.cs
blob: 1f0ef68ad794ea3c90a783724bd9891bf7d640a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
´╗┐using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

#if WINDOWS_UWP
[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.UWP.NativeValueConverterService))]
namespace Xamarin.Forms.Platform.UWP
#else
[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.WinRT.NativeValueConverterService))]
namespace Xamarin.Forms.Platform.WinRT
#endif
{
    public class NativeValueConverterService : Xaml.INativeValueConverterService
    {
        public bool ConvertTo(object value, Type toType, out object nativeValue)
        {
            nativeValue = null;
            if (typeof(FrameworkElement).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View)))
            {
                nativeValue = ((FrameworkElement)value).ToView();
                return true;
            }
            return false;
        }
    }
}