private void AttachViewModel()
{
if (DesignerProperties.GetIsInDesignMode(this))
{
return;
}
if (this.ViewModelType != null && this._viewModel == null)
{
this._viewModel = ViewModelFactory.Create(this.ViewModelType, this.FactoryContext);
}
if (this._viewModel != null)
{
this._viewModel.Model = this.DataContext;
this._viewModel.View = this.Child;
}
FrameworkElement childElement = this.Child as FrameworkElement;
if (childElement != null)
{
childElement.DataContext = this._viewModel;
}
}