public static bool SetColumnSizes(Grid grid, out List <object> columns)
        {
            if (CanSetGridSizes(grid, out columns))
            {
                Logger.Debug("Setting column values for grid ", LogSource.Layout, grid.Name);

                for (int i = 0; i < columns.Count; i++)
                {
                    ColumnSize size = (ColumnSize)columns[i];

                    // Set proper width for each column, specifiying a hardcoded en-US cultureinfo fixes a nasty parsing issue
                    grid.ColumnDefinitions[i].Width =
                        (GridLength) new GridLengthConverter().ConvertFrom(null, CultureInfo.GetCultureInfo("en-US"), size.Width);

                    if (size.IsCollapsed)
                    {
                        // Save previous size for restoring from collapsed state
                        SetPreviousGridLength(grid.ColumnDefinitions[i],
                                              (GridLength) new GridLengthConverter().ConvertFrom(size.PreviousWidth));
                    }

                    Logger.Debug("\tColumn {0} has Width {1}, Width from settings was {2}",
                                 LogSource.Layout, i, grid.ColumnDefinitions[i].Width, columns[i].ToString());
                }

                return(true);
            }

            return(false);
        }
        public static void SaveColumnSizes(Grid grid)
        {
            Logger.Debug("Storing column values for grid ", LogSource.Layout, grid.Name);

            for (int i = 0; i < grid.ColumnDefinitions.Count; i++)
            {
                string key = String.Format("/Settings/GridColumnSize/{0}/{1}", grid.Name, i);

                Logger.Debug("\tColumn {0} has Width {1}", LogSource.Layout, i, grid.ColumnDefinitions[i].Width);

                ColumnSize size = new ColumnSize {
                    Width = grid.ColumnDefinitions[i].Width.ToString()
                };

                if (grid.ColumnDefinitions[i].Width.Value == 0)
                {
                    size.IsCollapsed   = true;
                    size.PreviousWidth = GetPreviousGridLength(grid.ColumnDefinitions[i]).ToString();
                }

                // Watch the ToString call here, if you save a reference to the Width property, the value
                // will default to Auto during application shutdown because another Save call is triggered.
                ClientState.Current.Context.SaveSetting(key, size);
            }
        }