Example #1
0
        public Group()
        {
            InitializeComponent();

            m_custGrpStyle = (GroupStyle)FindResource("customGrpStyle");
            m_ageRange = new AgeRanger();
        }
Example #2
0
        static GroupStyle()
        { 
            ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StackPanel))); 
            template.Seal();
            DefaultGroupPanel = template; 

            s_DefaultGroupStyle = new GroupStyle();
        }
        public LogRecordsTableView()
        {
            InitializeComponent();

            _defaultGroupStyle = (GroupStyle) FindResource("groupStyle");
            InitDataGrid();

            Loaded += LogRecordsTableView_Loaded;
        }
Example #4
0
        //------------------------------------------------------
        //
        // Private Methods
        //
        //------------------------------------------------------

        // initialize (called during measure, from ApplyTemplate)
        void AttachToOwner()
        {
            DependencyObject       templatedParent = this.TemplatedParent;
            ItemsControl           owner           = templatedParent as ItemsControl;
            ItemContainerGenerator generator;

            if (owner != null)
            {
                // top-level presenter - get information from ItemsControl
                generator = owner.ItemContainerGenerator;
            }
            else
            {
                // subgroup presenter - get information from GroupItem
                GroupItem      parentGI = templatedParent as GroupItem;
                ItemsPresenter parentIP = FromGroupItem(parentGI);

                if (parentIP != null)
                {
                    owner = parentIP.Owner;
                }

                generator = (parentGI != null) ? parentGI.Generator : null;
            }

            _owner = owner;
            UseGenerator(generator);

            // create the panel, based either on ItemsControl.ItemsPanel or GroupStyle.Panel
            ItemsPanelTemplate template   = null;
            GroupStyle         groupStyle = (_generator != null) ? _generator.GroupStyle : null;

            if (groupStyle != null)
            {
                // If GroupStyle.Panel is set then we dont honor ItemsControl.IsVirtualizing
                template = groupStyle.Panel;
                if (template == null)
                {
                    // create default Panels
                    if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(owner))
                    {
                        template = GroupStyle.DefaultVirtualizingStackPanel;
                    }
                    else
                    {
                        template = GroupStyle.DefaultStackPanel;
                    }
                }
            }
            else
            {
                // Its a leaf-level ItemsPresenter, therefore pick ItemsControl.ItemsPanel
                template = (_owner != null) ? _owner.ItemsPanel : null;
            }
            Template = template;
        }
Example #5
0
        internal void ClearItemContainer(object item, ItemsControl parentItemsControl)
        {
            if (Generator == null)
            {
                return;     // user-declared GroupItem - ignore (bug 108423)
            }
            ItemContainerGenerator generator  = Generator.Parent;
            GroupStyle             groupStyle = generator.GroupStyle;

            if (Object.Equals(this.Content, item))
            {
                ClearValue(ContentProperty);
            }
            if (this.ContentTemplate == groupStyle.HeaderTemplate)
            {
                ClearValue(ContentTemplateProperty);
            }
            if (this.ContentTemplateSelector == groupStyle.HeaderTemplateSelector)
            {
                ClearValue(ContentTemplateSelectorProperty);
            }
            if (this.ContentStringFormat == groupStyle.HeaderStringFormat)
            {
                ClearValue(ContentStringFormatProperty);
            }

            //
            // ItemValueStorage:  save off values for this container if we're a virtualizing Group.
            //
            if (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl))
            {
                Helper.StoreItemValues((IContainItemStorage)parentItemsControl, this, item);

                if (_expander != null)
                {
                    Helper.StoreItemValues((IContainItemStorage)parentItemsControl, _expander, item);
                }

                // Tell the panel to clear off all its containers.  This will cause this method to be called
                // recursively down the tree, allowing all descendent data to be stored before we save off
                // the ItemValueStorage DP for this container.

                VirtualizingPanel vp = _itemsHost as VirtualizingPanel;
                if (vp != null)
                {
                    vp.OnClearChildrenInternal();
                }

                Generator.RemoveAllInternal(true /*saveRecycleQueue*/);
            }
            else
            {
                Generator.Release();
            }
        }
Example #6
0
        static GroupStyle()
        {
            ItemsPanelTemplate template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StackPanel)));

            template.Seal();
            DefaultGroupPanel = template;
            DefaultStackPanel = template;

            template = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(VirtualizingStackPanel)));
            template.Seal();
            DefaultVirtualizingStackPanel = template;

            s_DefaultGroupStyle = new GroupStyle();
        }
Example #7
0
        private void GroupByProperty(PropertyGroupDescription groupOption, GroupStyle grpStyle)
        {
            PersonCollection persons = (PersonCollection)FindResource("persons");
            ICollectionView view = CollectionViewSource.GetDefaultView(persons);

            if (view.GroupDescriptions.Count == 0)
            {
                view.GroupDescriptions.Add(groupOption);
                lbxPersons.GroupStyle.Add(grpStyle);
            }
            else
            {
                view.GroupDescriptions.Clear();
                lbxPersons.GroupStyle.Clear();
            }
        }
        // Token: 0x0600510F RID: 20751 RVA: 0x0016BAE4 File Offset: 0x00169CE4
        private void AttachToOwner()
        {
            DependencyObject       templatedParent = base.TemplatedParent;
            ItemsControl           itemsControl    = templatedParent as ItemsControl;
            ItemContainerGenerator generator;

            if (itemsControl != null)
            {
                generator = itemsControl.ItemContainerGenerator;
            }
            else
            {
                GroupItem      groupItem      = templatedParent as GroupItem;
                ItemsPresenter itemsPresenter = ItemsPresenter.FromGroupItem(groupItem);
                if (itemsPresenter != null)
                {
                    itemsControl = itemsPresenter.Owner;
                }
                generator = ((groupItem != null) ? groupItem.Generator : null);
            }
            this._owner = itemsControl;
            this.UseGenerator(generator);
            GroupStyle         groupStyle = (this._generator != null) ? this._generator.GroupStyle : null;
            ItemsPanelTemplate itemsPanelTemplate;

            if (groupStyle != null)
            {
                itemsPanelTemplate = groupStyle.Panel;
                if (itemsPanelTemplate == null)
                {
                    if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(itemsControl))
                    {
                        itemsPanelTemplate = GroupStyle.DefaultVirtualizingStackPanel;
                    }
                    else
                    {
                        itemsPanelTemplate = GroupStyle.DefaultStackPanel;
                    }
                }
            }
            else
            {
                itemsPanelTemplate = ((this._owner != null) ? this._owner.ItemsPanel : null);
            }
            this.Template = itemsPanelTemplate;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleElement"/> class.
 /// </summary>
 /// <param name="style">The style.</param>
 /// <param name="boundType">Type of the bound.</param>
 /// <param name="name">The name.</param>
 internal GroupStyleElement(GroupStyle style, BoundType boundType, string name)
 {
     _style = style;
     _type = boundType;
     _name = name + " [GroupStyle] ";
 }
Example #10
0
 public static void SetGroupStyle(DependencyObject obj, GroupStyle value)
 {
     obj.SetValue(GroupStyleProperty, value);
 }
Example #11
0
		// Token: 0x06004E0E RID: 19982 RVA: 0x0015FCB8 File Offset: 0x0015DEB8
		internal void PrepareItemContainer(object item, ItemsControl parentItemsControl)
		{
			if (this.Generator == null)
			{
				return;
			}
			if (this._itemsHost != null)
			{
				this._itemsHost.IsItemsHost = true;
			}
			bool flag = parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl);
			if (this.Generator != null)
			{
				if (!flag)
				{
					this.Generator.Release();
				}
				else
				{
					this.Generator.RemoveAllInternal(true);
				}
			}
			ItemContainerGenerator parent = this.Generator.Parent;
			GroupStyle groupStyle = parent.GroupStyle;
			Style style = groupStyle.ContainerStyle;
			if (style == null && groupStyle.ContainerStyleSelector != null)
			{
				style = groupStyle.ContainerStyleSelector.SelectStyle(item, this);
			}
			if (style != null)
			{
				if (!style.TargetType.IsInstanceOfType(this))
				{
					throw new InvalidOperationException(SR.Get("StyleForWrongType", new object[]
					{
						style.TargetType.Name,
						base.GetType().Name
					}));
				}
				base.Style = style;
				base.WriteInternalFlag2(InternalFlags2.IsStyleSetFromGenerator, true);
			}
			if (base.ContentIsItem || !base.HasNonDefaultValue(ContentControl.ContentProperty))
			{
				base.Content = item;
				base.ContentIsItem = true;
			}
			if (!base.HasNonDefaultValue(ContentControl.ContentTemplateProperty))
			{
				base.ContentTemplate = groupStyle.HeaderTemplate;
			}
			if (!base.HasNonDefaultValue(ContentControl.ContentTemplateSelectorProperty))
			{
				base.ContentTemplateSelector = groupStyle.HeaderTemplateSelector;
			}
			if (!base.HasNonDefaultValue(ContentControl.ContentStringFormatProperty))
			{
				base.ContentStringFormat = groupStyle.HeaderStringFormat;
			}
			Helper.ClearVirtualizingElement(this);
			if (flag)
			{
				Helper.SetItemValuesOnContainer(parentItemsControl, this, item);
				if (this._expander != null)
				{
					Helper.SetItemValuesOnContainer(parentItemsControl, this._expander, item);
				}
			}
		}
Example #12
0
        //------------------------------------------------------
        //
        // Internal Methods
        //
        //------------------------------------------------------

        internal void PrepareItemContainer(object item, ItemsControl parentItemsControl)
        {
            if (Generator == null)
            {
                return;     // user-declared GroupItem - ignore (
            }
            // If a GroupItem is being recycled set back IsItemsHost
            if (_itemsHost != null)
            {
                _itemsHost.IsItemsHost = true;
            }

            bool isVirtualizingWhenGrouping = (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl));

            // Release any previous containers. Also ensures Items and GroupStyle are hooked up correctly
            if (Generator != null)
            {
                if (!isVirtualizingWhenGrouping)
                {
                    Generator.Release();
                }
                else
                {
                    Generator.RemoveAllInternal(true /*saveRecycleQueue*/);
                }
            }

            ItemContainerGenerator generator  = Generator.Parent;
            GroupStyle             groupStyle = generator.GroupStyle;

            // apply the container style
            Style style = groupStyle.ContainerStyle;

            // no ContainerStyle set, try ContainerStyleSelector
            if (style == null)
            {
                if (groupStyle.ContainerStyleSelector != null)
                {
                    style = groupStyle.ContainerStyleSelector.SelectStyle(item, this);
                }
            }

            // apply the style, if found
            if (style != null)
            {
                // verify style is appropriate before applying it
                if (!style.TargetType.IsInstanceOfType(this))
                {
                    throw new InvalidOperationException(SR.Get(SRID.StyleForWrongType, style.TargetType.Name, this.GetType().Name));
                }

                this.Style = style;
                this.WriteInternalFlag2(InternalFlags2.IsStyleSetFromGenerator, true);
            }

            // forward the header template information
            if (ContentIsItem || !HasNonDefaultValue(ContentProperty))
            {
                this.Content  = item;
                ContentIsItem = true;
            }
            if (!HasNonDefaultValue(ContentTemplateProperty))
            {
                this.ContentTemplate = groupStyle.HeaderTemplate;
            }
            if (!HasNonDefaultValue(ContentTemplateSelectorProperty))
            {
                this.ContentTemplateSelector = groupStyle.HeaderTemplateSelector;
            }
            if (!HasNonDefaultValue(ContentStringFormatProperty))
            {
                this.ContentStringFormat = groupStyle.HeaderStringFormat;
            }

            //
            // Clear previously cached items sizes
            //
            Helper.ClearVirtualizingElement(this);

            //
            // ItemValueStorage:  restore saved values for this item onto the new container
            //
            if (isVirtualizingWhenGrouping)
            {
                Helper.SetItemValuesOnContainer(parentItemsControl, this, item);

                if (_expander != null)
                {
                    Helper.SetItemValuesOnContainer(parentItemsControl, _expander, item);
                }
            }
        }
        private void AddDataGrid(DataView dv, string strataValue)
        {
            DataGrid dg = new DataGrid();
            dg.Style = this.Resources["LineListDataGridStyle"] as Style;

            LineListParameters ListParameters = (this.Parameters) as LineListParameters;

            FrameworkElementFactory datagridRowsPresenter = new FrameworkElementFactory(typeof(DataGridRowsPresenter));
            ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate();
            itemsPanelTemplate.VisualTree = datagridRowsPresenter;
            GroupStyle groupStyle = new GroupStyle();
            groupStyle.ContainerStyle = this.Resources["DefaultGroupItemStyle"] as Style;
            groupStyle.Panel = itemsPanelTemplate;
            dg.GroupStyle.Add(groupStyle);

            GroupStyle groupStyle2 = new GroupStyle();
            groupStyle2.HeaderTemplate = this.Resources["GroupDataTemplate"] as DataTemplate;
            //groupStyle.Panel = itemsPanelTemplate;
            dg.GroupStyle.Add(groupStyle2);

            string groupVar = String.Empty;

            if (!String.IsNullOrEmpty(ListParameters.PrimaryGroupField.Trim()))
            {
                groupVar = ListParameters.PrimaryGroupField.Trim();
                ListCollectionView lcv = new ListCollectionView(dv);
                lcv.GroupDescriptions.Add(new PropertyGroupDescription(groupVar));
                if (!String.IsNullOrEmpty(ListParameters.SecondaryGroupField.Trim()) && !ListParameters.SecondaryGroupField.Trim().Equals(groupVar))
                {
                    lcv.GroupDescriptions.Add(new PropertyGroupDescription(ListParameters.SecondaryGroupField.Trim())); // for second category
                }
                dg.ItemsSource = lcv;

            }
            else
            {
                dg.ItemsSource = dv;
            }

            if (Parameters.Height.HasValue)
            {
                dg.MaxHeight = Parameters.Height.Value;
            }
            else
            {
                dg.MaxHeight = 700;
            }

            if (Parameters.Width.HasValue)
            {
                dg.MaxWidth = Parameters.Width.Value;
            }
            else
            {
                dg.MaxWidth = 900;
            }

            dg.AutoGeneratedColumns += new EventHandler(dg_AutoGeneratedColumns);
            dg.AutoGeneratingColumn += new EventHandler<DataGridAutoGeneratingColumnEventArgs>(dg_AutoGeneratingColumn);

            panelMain.Children.Add(dg);
        }
Example #14
0
        /// <summary>
        /// Creates a bound group style.
        /// </summary>
        /// <param name="groupStyle">The group style.</param>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
		public static IBoundElement GroupStyle(GroupStyle groupStyle, BoundType type, string name)
        {
            return new GroupStyleElement(groupStyle, type, name);
        }
Example #15
0
        /// <summary>
        /// Creates a bound group style.
        /// </summary>
        /// <param name="groupStyle">The group style.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
		public static IBoundElement GroupStyle(GroupStyle groupStyle, BoundType type)
        {
            return GroupStyle(groupStyle, type, string.Empty);
        }