summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP/NativeValueConverterService.cs
blob: 574f78ed8e5de950d018e450bfa9e7f56c9494ae (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
30
31
´╗┐using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Xaml.Internals;

#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 : 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;
        }
    }
}