private static void UpdateContent(UIView container, object value, IDataTemplateSelector selector)
        {
            var viewController = ServiceProvider
                .AttachedValueProvider
                .GetValue<UIViewController>(container, ContentControllerPath, false);
            if (viewController != null)
            {
                viewController.RemoveFromParentViewController();
                ServiceProvider.AttachedValueProvider.Clear(container, ContentControllerPath);
                viewController.InititalizeRestorationIdentifier();
            }

            if (selector != null)
                value = selector.SelectTemplateWithContext(value, container);
            var viewModel = value as IViewModel;
            if (viewModel != null)
                value = ViewModelToViewConverter.Instance.Convert(viewModel);

            viewController = value as UIViewController;
            if (viewController != null)
            {
                var currentController = container.FindParent<UIViewController>();
                if (currentController != null)
                {
                    ServiceProvider.AttachedValueProvider.SetValue(container, ContentControllerPath, viewController);
                    viewController.WillMoveToParentViewController(currentController);
                    currentController.AddChildViewController(viewController);
                    viewController.DidMoveToParentViewController(currentController);
                    PlatformExtensions.SetHasState(viewController, false);
                    value = viewController.View;
                }
            }


            var viewManager = container.GetBindingMemberValue(AttachedMembers.UIView.ContentViewManager);
            if (viewManager == null)
            {
                container.ClearSubViews();
                var view = value as UIView;
                if (view == null && value != null)
                    view = new UITextView(container.Frame)
                    {
                        Editable = false,
                        DataDetectorTypes = UIDataDetectorType.None,
                        Text = value.ToString()
                    };
                if (view != null)
                {
                    view.Frame = container.Frame;
                    view.AutoresizingMask = UIViewAutoresizing.All;
                    container.AddSubviewEx(view);
                }
            }
            else
                viewManager.SetContent(container, value);
        }
        private static void UpdateContent(UIView container, object value, IDataTemplateSelector selector)
        {
            var viewController = ServiceProvider
                                 .AttachedValueProvider
                                 .GetValue <UIViewController>(container, ContentControllerPath, false);

            if (viewController != null)
            {
                viewController.RemoveFromParentViewController();
                ServiceProvider.AttachedValueProvider.Clear(container, ContentControllerPath);
                viewController.InititalizeRestorationIdentifier();
            }

            if (selector != null)
            {
                value = selector.SelectTemplateWithContext(value, container);
            }
            var viewModel = value as IViewModel;

            if (viewModel != null)
            {
                value = ViewModelToViewConverter.Instance.Convert(viewModel);
            }

            var view = value as UIView;

            if (view == null)
            {
                viewController = value as UIViewController;
                if (viewController == null)
                {
                    if (value != null)
                    {
                        view = new UITextView(new RectangleF(4, 4, 300, 30))
                        {
                            Editable          = false,
                            DataDetectorTypes = UIDataDetectorType.None,
                            Text = value.ToString()
                        }
                    }
                    ;
                }
                else
                {
                    var currentController = container.FindParent <UIViewController>();
                    if (currentController != null)
                    {
                        ServiceProvider.AttachedValueProvider.SetValue(container, ContentControllerPath, viewController);
                        viewController.WillMoveToParentViewController(currentController);
                        currentController.AddChildViewController(viewController);
                        viewController.DidMoveToParentViewController(currentController);
                        viewController.RestorationIdentifier = string.Empty;
                        view = viewController.View;
                    }
                }
            }

            IContentViewManager viewManager = ContentViewManagerMember.GetValue(container, null);

            if (viewManager == null)
            {
                container.ClearSubViews();
                if (view != null)
                {
                    view.Frame            = container.Frame;
                    view.AutoresizingMask = UIViewAutoresizing.All;
                    container.AddSubviewEx(view);
                }
            }
            else
            {
                viewManager.SetContent(container, view);
            }
        }