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); } }
internal static FragmentManager GetFragmentManager(this View view) { var treeView = view; while (treeView != null) { var fragment = MvvmFragmentMediator.FragmentViewMember.GetValue(treeView, null); if (fragment != null) { return(fragment.ChildFragmentManager); } treeView = treeView.Parent as View; } var activity = view.Context.GetActivity(); if (activity == null) { Tracer.Warn("The activity is null {0}", view); return(null); } return(activity.GetFragmentManager()); }