예제 #1
0
        /// <summary>
        /// Ensures the that the view is a window or provides one.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        protected virtual ChildWindow EnsureWindow(object model, object view)
        {
            var window = view as ChildWindow;

            if (window == null)
            {
                window = new ChildWindow
                {
                    Content = view,
                };

                var presenter = model as IPresenter;
                if (presenter != null)
                {
                    var binding = new Binding("DisplayName")
                    {
                        Mode = BindingMode.TwoWay
                    };
                    window.SetBinding(ChildWindow.TitleProperty, binding);
                }
            }

            return(window);
        }