Ejemplo n.º 1
0
        /// <summary>
        /// Callback for displaying the Column Picker.
        /// </summary>
        /// <param name="sender">The send object.</param>
        /// <param name="e">The Event RoutedEventArgs.</param>
        internal void OnColumnPicker(object sender, RoutedEventArgs e)
        {
            ColumnPicker columnPicker = new ColumnPicker(
                this.Columns, this.AvailableColumns);

            columnPicker.Owner = Window.GetWindow((DependencyObject)sender);

            bool?retval = columnPicker.ShowDialog();

            if (true != retval)
            {
                return;
            }

            this.canChangeColumns = true;
            try
            {
                this.Columns.Clear();
                ObservableCollection <InnerListColumn> newColumns = columnPicker.SelectedColumns;
                Debug.Assert(null != newColumns, "SelectedColumns not found");
                foreach (InnerListColumn column in newColumns)
                {
                    Debug.Assert(column.Visible);

                    // 185977: ML InnerListGridView.PopulateColumns(): Always set Width on new columns
                    // Workaround to GridView issue suggested by Ben Carter
                    // Issue: Once a column has been added to a GridView
                    //   and then removed, auto-sizing does not work
                    //   after it is added back.
                    // Solution: Remove the column, change the width,
                    //   add the column back, then change the width back.

                    double width = column.Width;
                    column.Width = 0d;
                    this.Columns.Add(column);
                    column.Width = width;
                }
            }
            finally
            {
                this.canChangeColumns = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Callback for displaying the Column Picker.
        /// </summary>
        /// <param name="sender">The send object.</param>
        /// <param name="e">The Event RoutedEventArgs.</param>
        internal void OnColumnPicker(object sender, RoutedEventArgs e)
        {
            ColumnPicker columnPicker = new ColumnPicker(
                this.Columns, this.AvailableColumns);
            columnPicker.Owner = Window.GetWindow((DependencyObject)sender);

            bool? retval = columnPicker.ShowDialog();
            if (true != retval)
            {
                return;
            }

            this.canChangeColumns = true;
            try
            {
                this.Columns.Clear();
                ObservableCollection<InnerListColumn> newColumns = columnPicker.SelectedColumns;
                Debug.Assert(null != newColumns, "SelectedColumns not found");
                foreach (InnerListColumn column in newColumns)
                {
                    Debug.Assert(column.Visible);

                    // 185977: ML InnerListGridView.PopulateColumns(): Always set Width on new columns
                    // Workaround to GridView issue suggested by Ben Carter
                    // Issue: Once a column has been added to a GridView
                    //   and then removed, auto-sizing does not work
                    //   after it is added back.
                    // Solution: Remove the column, change the width,
                    //   add the column back, then change the width back.

                    double width = column.Width;
                    column.Width = 0d;
                    this.Columns.Add(column);
                    column.Width = width;
                }
            }
            finally
            {
                this.canChangeColumns = false;
            }
        }