コード例 #1
0
        private void UpdateView(IEnumerable value)
        {
            // NOTE : We need to clear the SortDescription before
            // clearing the InnerGrid.Columns so that the Adorners
            // are appropriately cleared.
            InnerListColumn sortedColumn = this.SortedColumn;

            this.ClearSort();

            // Release the current inner grid \\
            this.ReleaseInnerGridReferences();

            if (this.AutoGenerateColumns)
            {
                this.innerGrid = new InnerListGridView();

                // PopulateColumns deals with a null newEnumerable
                this.innerGrid.PopulateColumns(value);
            }
            else
            {
                this.innerGrid = new InnerListGridView(this.Columns);
            }

            this.View = this.innerGrid;
            this.SetColumnHeaderActions();

            if (null != sortedColumn && this.Columns.Contains(sortedColumn))
            {
                this.ApplySort(sortedColumn, false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Called when the ItemsSource changes to set internal fields, subscribe to the view change
        /// and possibly autopopulate columns.
        /// </summary>
        /// <param name="oldValue">Previous ItemsSource.</param>
        /// <param name="newValue">Current ItemsSource.</param>
        protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue)
        {
            base.OnItemsSourceChanged(oldValue, newValue);

            this.itemsSourceIsEmpty = (null != this.ItemsSource && false == this.ItemsSource.GetEnumerator().MoveNext());

            // A view can be created if there is data to auto-generate columns, or columns are added programatically \\
            bool canCreateView = (null != this.ItemsSource) &&
                                 (false == this.itemsSourceIsEmpty || false == this.AutoGenerateColumns);

            if (canCreateView)
            {
                this.UpdateViewAndCollectionView(this.ItemsSource);

                // If there are items, select the first item now \\
                this.SelectedIndex = this.itemsSourceIsEmpty ? -1 : 0;
            }
            else
            {
                // Release the current inner grid \\
                this.ReleaseInnerGridReferences();

                // clean up old state if can not set the state.
                this.SetCollectionView(null);
                this.innerGrid = null;
                this.View      = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Called when the View property is changed.
        /// </summary>
        /// <param name="obj">InnerList whose property is being changed.</param>
        /// <param name="e">Event arguments.</param>
        private static void InnerList_OnViewChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            InnerList         thisList  = (InnerList)obj;
            GridView          newGrid   = e.NewValue as GridView;
            InnerListGridView innerGrid = e.NewValue as InnerListGridView;

            if (newGrid != null && innerGrid == null)
            {
                throw new NotSupportedException(String.Format(
                                                    CultureInfo.InvariantCulture,
                                                    InvariantResources.ViewSetWithType,
                                                    typeof(GridView).Name,
                                                    typeof(InnerListGridView).Name));
            }

            ((InnerList)obj).innerGrid = innerGrid;
        }
コード例 #4
0
ファイル: Innerlist.cs プロジェクト: dfinke/powershell
        private void UpdateView(IEnumerable value)
        {
            // NOTE : We need to clear the SortDescription before
            // clearing the InnerGrid.Columns so that the Adorners
            // are appropriately cleared.
            InnerListColumn sortedColumn = this.SortedColumn;
            this.ClearSort();

            // Release the current inner grid \\
            this.ReleaseInnerGridReferences();

            if (this.AutoGenerateColumns)
            {
                this.innerGrid = new InnerListGridView();

                // PopulateColumns deals with a null newEnumerable
                this.innerGrid.PopulateColumns(value);
            }
            else
            {
                this.innerGrid = new InnerListGridView(this.Columns);
            }

            this.View = this.innerGrid;
            this.SetColumnHeaderActions();

            if (null != sortedColumn && this.Columns.Contains(sortedColumn))
            {
                this.ApplySort(sortedColumn, false);
            }
        }
コード例 #5
0
ファイル: Innerlist.cs プロジェクト: dfinke/powershell
        /// <summary>
        /// Called when the ItemsSource changes to set internal fields, subscribe to the view change 
        /// and possibly autopopulate columns.
        /// </summary>
        /// <param name="oldValue">Previous ItemsSource.</param>
        /// <param name="newValue">Current ItemsSource.</param>
        protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue)
        {
            base.OnItemsSourceChanged(oldValue, newValue);

            this.itemsSourceIsEmpty = (null != this.ItemsSource && false == this.ItemsSource.GetEnumerator().MoveNext());

            // A view can be created if there is data to auto-generate columns, or columns are added programmatically \\
            bool canCreateView = (null != this.ItemsSource) &&
                (false == this.itemsSourceIsEmpty || false == this.AutoGenerateColumns);

            if (canCreateView)
            {
                this.UpdateViewAndCollectionView(this.ItemsSource);

                // If there are items, select the first item now \\
                this.SelectedIndex = this.itemsSourceIsEmpty ? -1 : 0;
            }
            else
            {
                // Release the current inner grid \\
                this.ReleaseInnerGridReferences();

                // clean up old state if can not set the state.
                this.SetCollectionView(null);
                this.innerGrid = null;
                this.View = null;
            }
        }