/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <UIElement_Goo> elementsToAdd = new List <UIElement_Goo>();
            double        width           = 0;
            double        height          = 0;
            List <string> rowDefinitions  = new List <string>();
            List <string> colDefinitions  = new List <string>();
            List <int>    elementRows     = new List <int>();
            List <int>    elementCols     = new List <int>();
            List <int>    elementRowSpans = new List <int>();
            List <int>    elementColSpans = new List <int>();



            if (!DA.GetDataList <UIElement_Goo>("UI Elements", elementsToAdd))
            {
                return;
            }
            bool hasWidth  = DA.GetData <double>("Width", ref width);
            bool hasHeight = DA.GetData <double>("Height", ref height);

            bool hasRowDefs = DA.GetDataList <string>("Row Definitions", rowDefinitions);
            bool hasColDefs = DA.GetDataList <string>("Column Definitions", colDefinitions);

            bool hasElementRows = DA.GetDataList <int>("Element Row", elementRows);
            bool hasElementCols = DA.GetDataList <int>("Element Column", elementCols);

            DA.GetDataList <int>("Element Row Span", elementRowSpans);
            DA.GetDataList <int>("Element Column Span", elementColSpans);

            //initialize the grid
            Grid grid = new Grid();

            grid.HorizontalAlignment = HorizontalAlignment.Left;
            grid.VerticalAlignment   = VerticalAlignment.Top;
            grid.Name = "GH_Grid";
            if (hasWidth)
            {
                grid.Width = width;
            }
            else
            {
                grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            }
            if (hasHeight)
            {
                grid.Height = height;
            }
            else
            {
                grid.VerticalAlignment = VerticalAlignment.Stretch;
            }


            //set up a "GridLengthConverter" to handle parsing our strings.
            GridLengthConverter gridLengthConverter = new GridLengthConverter();

            //set up rows and columns if present
            if (hasColDefs)
            {
                foreach (string colDef in colDefinitions)
                {
                    ColumnDefinition cd = new ColumnDefinition();
                    cd.Width = (GridLength)gridLengthConverter.ConvertFromString(colDef);
                    grid.ColumnDefinitions.Add(cd);
                }
            }
            if (hasRowDefs)
            {
                foreach (string rowDef in rowDefinitions)
                {
                    RowDefinition rd = new RowDefinition();
                    rd.Height = (GridLength)gridLengthConverter.ConvertFromString(rowDef);
                    grid.RowDefinitions.Add(rd);
                }
            }


            //for all the elements to add
            for (int i = 0; i < elementsToAdd.Count; i++)
            {
                UIElement_Goo u = elementsToAdd[i];
                //make sure it doesn't already have a parent
                HUI_Util.removeParent(u.element);
                FrameworkElement fe = u.element as FrameworkElement;
                if (fe != null)
                {
                    //set its alignment to be relative to upper left - this makes margin-based positioning easy
                    fe.HorizontalAlignment = HorizontalAlignment.Left;
                    fe.VerticalAlignment   = VerticalAlignment.Top;

                    //set up row and column positioning + spans
                    if (hasElementCols && elementCols.Count > 0 && elementColSpans.Count > 0)
                    {
                        Grid.SetColumn(fe, elementCols[i % elementCols.Count]); // using hacky fake longest list matching. Will create a repeating pattern if it doesn't know what to do.
                        Grid.SetColumnSpan(fe, elementColSpans[i % elementColSpans.Count]);
                    }
                    if (hasElementRows && elementRows.Count > 0 && elementRowSpans.Count > 0)
                    {
                        Grid.SetRow(fe, elementRows[i % elementRows.Count]); // using hacky fake longest list matching. Will create a repeating pattern if it doesn't know what to do.
                        Grid.SetRowSpan(fe, elementRowSpans[i % elementRowSpans.Count]);
                    }
                }
                //add it to the grid
                grid.Children.Add(u.element);
            }
            //pass the grid out
            DA.SetData("Grid", new UIElement_Goo(grid, "Grid", InstanceGuid, DA.Iteration));
        }