Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / GroupItem.cs / 1305600 / GroupItem.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: GroupItem object - root of the UI subtree generated for a CollectionViewGroup
//
// Specs: http://avalon/connecteddata/M5%20General%20Docs/Data%20Styling.mht
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
namespace System.Windows.Controls
{
///
/// A GroupItem appears as the root of the visual subtree generated for a CollectionViewGroup.
///
public class GroupItem : ContentControl
{
static GroupItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(GroupItem), new FrameworkPropertyMetadata(typeof(GroupItem)));
_dType = DependencyObjectType.FromSystemTypeInternal(typeof(GroupItem));
// GroupItems should not be focusable by default
FocusableProperty.OverrideMetadata(typeof(GroupItem), new FrameworkPropertyMetadata(false));
}
///
/// Creates AutomationPeer ( )
///
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return new System.Windows.Automation.Peers.GroupItemAutomationPeer(this);
}
///
/// Gives a string representation of this object.
///
///
internal override string GetPlainText()
{
System.Windows.Data.CollectionViewGroup cvg = Content as System.Windows.Data.CollectionViewGroup;
if (cvg != null && cvg.Name != null)
{
return cvg.Name.ToString();
}
return base.GetPlainText();
}
//-----------------------------------------------------
//
// Internal Properties
//
//-----------------------------------------------------
internal ItemContainerGenerator Generator { get { return _generator; } set { _generator = value; } }
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
internal void PrepareItemContainer(object item)
{
if (Generator == null)
return; // user-declared GroupItem - ignore (bug 108423)
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 (!HasNonDefaultValue(ContentProperty))
this.Content = item;
if (!HasNonDefaultValue(ContentTemplateProperty))
this.ContentTemplate = groupStyle.HeaderTemplate;
if (!HasNonDefaultValue(ContentTemplateSelectorProperty))
this.ContentTemplateSelector = groupStyle.HeaderTemplateSelector;
if (!HasNonDefaultValue(ContentStringFormatProperty))
this.ContentStringFormat = groupStyle.HeaderStringFormat;
}
internal void ClearContainerForItem(object item)
{
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);
Generator.Release();
}
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
ItemContainerGenerator _generator;
#region DTypeThemeStyleKey
// Returns the DependencyObjectType for the registered ThemeStyleKey's default
// value. Controls will override this method to return approriate types.
internal override DependencyObjectType DTypeThemeStyleKey
{
get { return _dType; }
}
private static DependencyObjectType _dType;
#endregion DTypeThemeStyleKey
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: GroupItem object - root of the UI subtree generated for a CollectionViewGroup
//
// Specs: http://avalon/connecteddata/M5%20General%20Docs/Data%20Styling.mht
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
namespace System.Windows.Controls
{
///
/// A GroupItem appears as the root of the visual subtree generated for a CollectionViewGroup.
///
public class GroupItem : ContentControl
{
static GroupItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(GroupItem), new FrameworkPropertyMetadata(typeof(GroupItem)));
_dType = DependencyObjectType.FromSystemTypeInternal(typeof(GroupItem));
// GroupItems should not be focusable by default
FocusableProperty.OverrideMetadata(typeof(GroupItem), new FrameworkPropertyMetadata(false));
}
///
/// Creates AutomationPeer ( )
///
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return new System.Windows.Automation.Peers.GroupItemAutomationPeer(this);
}
///
/// Gives a string representation of this object.
///
///
internal override string GetPlainText()
{
System.Windows.Data.CollectionViewGroup cvg = Content as System.Windows.Data.CollectionViewGroup;
if (cvg != null && cvg.Name != null)
{
return cvg.Name.ToString();
}
return base.GetPlainText();
}
//-----------------------------------------------------
//
// Internal Properties
//
//-----------------------------------------------------
internal ItemContainerGenerator Generator { get { return _generator; } set { _generator = value; } }
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
internal void PrepareItemContainer(object item)
{
if (Generator == null)
return; // user-declared GroupItem - ignore (bug 108423)
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 (!HasNonDefaultValue(ContentProperty))
this.Content = item;
if (!HasNonDefaultValue(ContentTemplateProperty))
this.ContentTemplate = groupStyle.HeaderTemplate;
if (!HasNonDefaultValue(ContentTemplateSelectorProperty))
this.ContentTemplateSelector = groupStyle.HeaderTemplateSelector;
if (!HasNonDefaultValue(ContentStringFormatProperty))
this.ContentStringFormat = groupStyle.HeaderStringFormat;
}
internal void ClearContainerForItem(object item)
{
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);
Generator.Release();
}
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
ItemContainerGenerator _generator;
#region DTypeThemeStyleKey
// Returns the DependencyObjectType for the registered ThemeStyleKey's default
// value. Controls will override this method to return approriate types.
internal override DependencyObjectType DTypeThemeStyleKey
{
get { return _dType; }
}
private static DependencyObjectType _dType;
#endregion DTypeThemeStyleKey
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HyperlinkAutomationPeer.cs
- DocobjHost.cs
- BmpBitmapEncoder.cs
- SecurityChannelListener.cs
- WebPartConnectionsDisconnectVerb.cs
- QualifiedCellIdBoolean.cs
- PathFigureCollection.cs
- DynamicResourceExtension.cs
- UInt64Storage.cs
- ViewEvent.cs
- TdsParserStaticMethods.cs
- Collection.cs
- WebPermission.cs
- WebServiceErrorEvent.cs
- Int64AnimationBase.cs
- XamlWriter.cs
- PageCodeDomTreeGenerator.cs
- Visitor.cs
- DocumentPageViewAutomationPeer.cs
- PieceDirectory.cs
- SqlConnectionString.cs
- CodeArgumentReferenceExpression.cs
- PackageFilter.cs
- XmlConvert.cs
- ReferencedType.cs
- Win32PrintDialog.cs
- CrossAppDomainChannel.cs
- querybuilder.cs
- MarkupProperty.cs
- ETagAttribute.cs
- TraceSection.cs
- ImageField.cs
- MetadataProperty.cs
- SynchronizedInputHelper.cs
- Crypto.cs
- PropertyChangeTracker.cs
- DataControlImageButton.cs
- TraceHandlerErrorFormatter.cs
- MsmqMessageSerializationFormat.cs
- TreeWalker.cs
- ToolBarOverflowPanel.cs
- FixedSOMFixedBlock.cs
- WindowsIdentity.cs
- ComplusEndpointConfigContainer.cs
- RadioButtonPopupAdapter.cs
- CopyOfAction.cs
- XamlToRtfWriter.cs
- QuestionEventArgs.cs
- InternalTransaction.cs
- SerialStream.cs
- FrameDimension.cs
- CaseDesigner.xaml.cs
- AttributeInfo.cs
- NegationPusher.cs
- Registration.cs
- SafeHandles.cs
- WebPartActionVerb.cs
- TabControlCancelEvent.cs
- SchemaType.cs
- RegisteredHiddenField.cs
- ColumnMapVisitor.cs
- SweepDirectionValidation.cs
- TransformerInfoCollection.cs
- safesecurityhelperavalon.cs
- SharedUtils.cs
- ColumnHeaderConverter.cs
- ToolStripMenuItem.cs
- SBCSCodePageEncoding.cs
- HttpHandlersSection.cs
- Image.cs
- XPathParser.cs
- TypedDataSourceCodeGenerator.cs
- ThreadAbortException.cs
- _BaseOverlappedAsyncResult.cs
- LineVisual.cs
- TextHidden.cs
- BindingGroup.cs
- XslTransform.cs
- SynchronousSendBindingElement.cs
- CancellationToken.cs
- GenericAuthenticationEventArgs.cs
- DataGridDesigner.cs
- TemplateComponentConnector.cs
- XslAst.cs
- SHA256.cs
- SourceFilter.cs
- ImageListImageEditor.cs
- WrappedReader.cs
- SoapSchemaMember.cs
- EntityDataSourceConfigureObjectContext.cs
- FormViewUpdatedEventArgs.cs
- ForeignConstraint.cs
- httpserverutility.cs
- EntityDataSourceViewSchema.cs
- FixedSOMSemanticBox.cs
- MasterPageParser.cs
- CustomCategoryAttribute.cs
- TextMessageEncoder.cs
- DataGridViewEditingControlShowingEventArgs.cs
- IndependentAnimationStorage.cs