void OnFreeFormPanelRequiredSizeChanged(object sender, RequiredSizeChangedEventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                // Access the view state dictionary directly to avoid generating an undo item because of ViewStateAttachedPropertyFeature implementation.
                Dictionary<string, object> viewState = WorkflowViewStateService.GetViewState(this.ModelItem.GetCurrentValue());
                if (viewState == null)
                {
                    viewState = new Dictionary<string, object>();
                    WorkflowViewStateService.SetViewState(this.ModelItem.GetCurrentValue(), viewState);
                }

                if (e.NewRequiredSize.Width > this.FlowchartWidth)
                {
                    viewState[FlowchartSizeFeature.WidthPropertyName] = e.NewRequiredSize.Width;
                    this.FlowchartWidth = e.NewRequiredSize.Width;
                }

                if (e.NewRequiredSize.Height > this.FlowchartHeight)
                {
                    viewState[FlowchartSizeFeature.HeightPropertyName] = e.NewRequiredSize.Height;
                    this.FlowchartHeight = e.NewRequiredSize.Height;
                }
            });
        }
 void OnFreeFormPanelRequiredSizeChanged(object sender, RequiredSizeChangedEventArgs e)
 {
     this.requiredSize = e.NewRequiredSize;
     Dispatcher.BeginInvoke(new Action(() =>
     {
         if (this.requiredSize.Width > this.StateContainerWidth)
         {
             this.ViewStateService.StoreViewState(
                 this.ModelItem,
                 StateContainerEditor.StateContainerWidthViewStateKey,
                 this.requiredSize.Width);
         }
         if (this.requiredSize.Height > this.StateContainerHeight)
         {
             this.ViewStateService.StoreViewState(
                 this.ModelItem,
                 StateContainerEditor.StateContainerHeightViewStateKey,
                 this.requiredSize.Height);
         }
     }));
 }