コード例 #1
0
        /// <summary>
        /// This delagate is called when the view model is changed.
        /// </summary>
        /// <param name="pSender">The event sender.</param>
        /// <param name="pEventArgs">The event arguments.</param>
        private static void OnViewModelChanged(DependencyObject pSender, DependencyPropertyChangedEventArgs pEventArgs)
        {
            ExtendedListView lExtendedListView = pSender as ExtendedListView;

            if (lExtendedListView != null)
            {
                // Unloading the old view model.
                IRootHierarchicalItemViewModel lOldViewModel = pEventArgs.OldValue as IRootHierarchicalItemViewModel;
                if (lOldViewModel != null)
                {
                    // Unregistering from items modification events.
                    lOldViewModel.ItemViewModelsAdded   -= lExtendedListView.OnItemViewModelsAdded;
                    lOldViewModel.ItemViewModelsRemoved -= lExtendedListView.OnItemViewModelsRemoved;
                    lOldViewModel.ItemViewModelMoved    -= lExtendedListView.OnItemViewModelMoved;

                    // Initializing the view model.
                    lExtendedListView.DropChildrenItems(lOldViewModel, false);
                }

                // Loading the new view model.
                IRootHierarchicalItemViewModel lNewViewModel = pEventArgs.NewValue as IRootHierarchicalItemViewModel;
                if (lNewViewModel != null)
                {
                    // Registering on items modification events.
                    lNewViewModel.ItemViewModelsAdded   += lExtendedListView.OnItemViewModelsAdded;
                    lNewViewModel.ItemViewModelsRemoved += lExtendedListView.OnItemViewModelsRemoved;
                    lNewViewModel.ItemViewModelMoved    += lExtendedListView.OnItemViewModelMoved;

                    // Loading the first level items.
                    lExtendedListView.LoadsChildrenItems(lNewViewModel);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColumnResizeBehavior"/> class.
        /// </summary>
        /// <param name="pListView">The managed list view.</param>
        public ColumnResizeBehavior(ExtendedListView pListView)
        {
            if (pListView == null)
            {
                throw new ArgumentNullException("pListView");
            }

            this.mVerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            this.mListView = pListView;
            this.mListView.Loaded += new RoutedEventHandler(this.OnListViewLoaded);
            this.mListView.Unloaded += new RoutedEventHandler(this.OnListViewUnloaded);
        }
コード例 #3
0
ファイル: RowsCollection.cs プロジェクト: mastertnt/XRay
        /// <summary>
        /// Initializes a new instance of the <see cref="RowsCollection"/> class.
        /// </summary>
        /// <param name="pOwner">The collection owner.</param>
        public RowsCollection(ExtendedListView pOwner)
        {
            this.mOwner = pOwner;

            // Creating the source collection.
            this.mSource            = new ObservableCollection <IHierarchicalItemViewModel>();
            this.mViewSource        = new CollectionViewSource();
            this.mViewSource.Source = this.mSource;

            // Bind it the owner items source property.
            Binding lItemsSourceBinding = new Binding();

            lItemsSourceBinding.Source = this.mViewSource;
            this.mOwner.SetBinding(ExtendedListView.ItemsSourceProperty, lItemsSourceBinding);
        }
コード例 #4
0
ファイル: ExpandBehavior.cs プロジェクト: mastertnt/XRay
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpandBehavior"/> class.
 /// </summary>
 /// <param name="pParent">The behavior's parent.</param>
 public ExpandBehavior(ExtendedListView pParent)
 {
     this.mParent = pParent;
 }
コード例 #5
0
ファイル: SelectionModel.cs プロジェクト: mastertnt/XRay
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectionModel"/> class.
 /// </summary>
 /// <param name="pParent">The model parent.</param>
 public SelectionModel(ExtendedListView pParent)
 {
     this.mParent = pParent;
     this.mCanSelect = true;
     this.mSelectedItemsViewModel = new ObservableCollection<IHierarchicalItemViewModel>();
 }
コード例 #6
0
ファイル: SelectionBehavior.cs プロジェクト: mastertnt/XRay
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectionBehavior"/> class.
 /// </summary>
 /// <param name="pParent">The behavior's parent.</param>
 public SelectionBehavior(ExtendedListView pParent)
 {
     this.mParent = pParent;
 }
コード例 #7
0
ファイル: TreeListView.cs プロジェクト: mastertnt/XRay
        /// <summary>
        /// Called when the control template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Getting the parts from the control template.
            this.InnerListView = this.GetTemplateChild(PART_ListView) as ExtendedListView;
            this.mDefaultMessage = this.GetTemplateChild(PART_DefaultMessage) as Label;

            if  (   (this.InnerListView == null)
                ||  (this.mDefaultMessage == null)
                )
            {
                throw new Exception("TreeListView control template not correctly defined.");
            }

            IsParentTreeMultiColumnsBehavior.SetIsParentTreeMultiColumns(this, false);

            // Loading the view model.
            this.LoadViewModel();

            // Applying the selection option.
            this.InnerListView.SelectionModel.SelectionOption = this.mPendingSelectionOption;

            // Registering on the collection changed event for the selected and checked items.
            this.InnerListView.SelectionModel.SelectionChanged += this.OnInnerListViewSelectionChanged;
            this.InnerListView.CheckModel.ItemsViewModelToggled += this.OnInnerListItemsViewModelToggled;
            this.InnerListView.ItemViewModelsAdded += this.OnInnerListViewItemViewModelsAdded;
            this.InnerListView.ItemViewModelsRemoved += this.OnInnerListViewItemViewModelsRemoved;
            this.InnerListView.ItemViewModelDoubleClicked += this.OnInnerListViewItemViewModelDoubleClicked;

            // Setting the columns.
            TreeListViewColumnCollection lCollection = TreeListView.GetColumnsCollection(this) as TreeListViewColumnCollection;
            if (lCollection != null && lCollection.Count > 0)
            {
                // Creating the grid.
                ExtendedGridView lGridView = new ExtendedGridView(this.mResources, this.MultiColumnsItemContainerDefaultStyleKey);

                foreach (TreeListViewColumn lColumn in lCollection)
                {
                    if (lCollection[0] == lColumn)
                    {
                        lGridView.SetFirstColumn(lColumn);
                    }
                    else
                    {
                        lGridView.AddColumn(lColumn);
                    }
                }

                // Setting the grid view to the inner list.
                this.InnerListView.View = lGridView;

                IsParentTreeMultiColumnsBehavior.SetIsParentTreeMultiColumns(this, true);
            }
        }
コード例 #8
0
ファイル: ExpandModel.cs プロジェクト: mastertnt/XRay
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpandModel"/> class.
 /// </summary>
 /// <param name="pParent">The model parent.</param>
 public ExpandModel(ExtendedListView pParent)
 {
     this.mParent = pParent;
 }