summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/NativeValueConverterService.cs
blob: acdd652303c8bff1afcb4a02583b91087c8b91ee (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
using System;
#if __MOBILE__
using UIKit;
[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.iOS.NativeValueConverterService))]
namespace Xamarin.Forms.Platform.iOS
#else
using UIView = AppKit.NSView;

[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.MacOS.NativeValueConverterService))]

namespace Xamarin.Forms.Platform.MacOS
#endif
{
	class NativeValueConverterService : Xaml.INativeValueConverterService
	{
		public bool ConvertTo(object value, Type toType, out object nativeValue)
		{
			nativeValue = null;
			if (typeof(UIView).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View)))
			{
				nativeValue = ((UIView)value).ToView();
				return true;
			}
			return false;
		}
	}
}