private static void UpdateContent(Control container, object value, IDataTemplateSelector selector) { if (selector != null) { value = selector.SelectTemplateWithContext(value, container); } var content = value as Control; if (content == null) { var viewModel = value as IViewModel; if (viewModel != null) { content = ViewModelToViewConverter.Instance.Convert(viewModel) as Control; } } if (content == null && value != null) { Tracer.Warn("The content value {0} is not a Control.", value); content = new TextBox { ReadOnly = true, Text = value.ToString(), Multiline = true }; } IContentViewManager viewManager = ContentViewManagerMember.GetValue(container, null); if (viewManager == null) { container.Controls.Clear(); if (content != null) { content.Dock = DockStyle.Fill; content.AutoSize = true; container.Size = content.Size; container.Controls.Add(content); } } else { viewManager.SetContent(container, content); } }
private static void UpdateContent(Control container, object value, IDataTemplateSelector selector) { if (selector != null) { value = selector.SelectTemplateWithContext(value, container); } var viewModel = value as IViewModel; if (viewModel != null) { value = ViewModelToViewConverter.Instance.Convert(viewModel); } var viewManager = container.GetBindingMemberValue(AttachedMembers.Control.ContentViewManager); if (viewManager == null) { container.Controls.Clear(); var content = value as Control; if ((content == null) && (value != null)) { content = new TextBox { ReadOnly = true, Text = value.ToString(), Multiline = true } } ; if (content != null) { content.Dock = DockStyle.Fill; content.AutoSize = true; container.Size = content.Size; container.Controls.Add(content); } } 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); } 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); TouchToolkitExtensions.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); 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(Control container, object value, IDataTemplateSelector selector) { if (selector != null) value = selector.SelectTemplateWithContext(value, container); var viewModel = value as IViewModel; if (viewModel != null) value = ViewModelToViewConverter.Instance.Convert(viewModel); var viewManager = container.GetBindingMemberValue(AttachedMembers.Control.ContentViewManager); if (viewManager == null) { container.Controls.Clear(); var content = value as Control; if (content == null && value != null) content = new TextBox { ReadOnly = true, Text = value.ToString(), Multiline = true }; if (content != null) { content.Dock = DockStyle.Fill; content.AutoSize = true; container.Size = content.Size; container.Controls.Add(content); } } else viewManager.SetContent(container, value); }