Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Controls / ItemsPanelTemplate.cs / 1 / ItemsPanelTemplate.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: ItemsPanelTemplate describes how ItemsPresenter creates the panel // that manages layout of containers for an ItemsControl. // // Specs: // //--------------------------------------------------------------------------- using System.ComponentModel; using System.Windows.Controls; using System.Windows.Markup; using System.Diagnostics; namespace System.Windows.Controls { ////// ItemsPanelTemplate describes how ItemsPresenter creates the panel /// that manages layout of containers for an ItemsControl. /// public class ItemsPanelTemplate : FrameworkTemplate { #region Constructors //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- ////// ItemsPanelTemplate Constructor /// public ItemsPanelTemplate() { } ////// ItemsPanelTemplate Constructor /// public ItemsPanelTemplate(FrameworkElementFactory root) { VisualTree = root; } #endregion Constructors #region Public Properties //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #endregion PublicProperties #region Internal Properties //-------------------------------------------------------------------- // // Internal Properties // //-------------------------------------------------------------------- // // TargetType for ItemsPanelTemplate. This is override is // so FrameworkTemplate can see this property. // internal override Type TargetTypeInternal { get { return DefaultTargetType; } } // Subclasses must provide a way for the parser to directly set the // target type. For ItemsPanelTemplate, this is not allowed. internal override void SetTargetTypeInternal(Type targetType) { throw new InvalidOperationException(SR.Get(SRID.TemplateNotTargetType)); } // Target type of ItemsPanelTemplate is ItemsPresenter static internal Type DefaultTargetType { get { return typeof(ItemsPresenter); } } #endregion Internal Properties #region Internal Methods //------------------------------------------------------------------- // // Internal Methods // //-------------------------------------------------------------------- // // ProcessTemplateBeforeSeal // // This is used in the case of templates defined with FEFs. For templates // in Baml (the typical case), see the OnApply override. // // 1. Verify that // a. root element is a Panel // 2. Set IsItemsHost = true // internal override void ProcessTemplateBeforeSeal() { FrameworkElementFactory root; if( HasContent ) { // This is a Baml-style template // Validate the root type (it must be a Panel) if (!typeof(Panel).IsAssignableFrom(OptimizedTemplateContent.RootType)) throw new InvalidOperationException(SR.Get(SRID.ItemsPanelNotAPanel, OptimizedTemplateContent.RootType)); // Set the IsItemsHost property on the root, via the template tables BamlNamedElementStartRecord bamlNamedElementStartRecord = OptimizedTemplateContent.UnsharedContent as BamlNamedElementStartRecord; SharedDp sharedDp = new SharedDp( Panel.IsItemsHostProperty, true, bamlNamedElementStartRecord.RuntimeName ); OptimizedTemplateContent.SharedProperties.Add( sharedDp ); } else if ((root = this.VisualTree) != null) { // This is a FEF-style template if (!typeof(Panel).IsAssignableFrom(root.Type)) throw new InvalidOperationException(SR.Get(SRID.ItemsPanelNotAPanel, root.Type)); root.SetValue(Panel.IsItemsHostProperty, true); } } #endregion Internal Methods #region Protected Methods //------------------------------------------------------------------- // // Protected Methods // //------------------------------------------------------------------- ////// Validate against the following rules /// 1. Must have a non-null feTemplatedParent /// 2. A ItemsPanelTemplate must be applied to a ContentPresenter /// protected override void ValidateTemplatedParent(FrameworkElement templatedParent) { // Must have a non-null feTemplatedParent if (templatedParent == null) { throw new ArgumentNullException("templatedParent"); } // A ItemsPanelTemplate must be applied to an ItemsPresenter if (!(templatedParent is ItemsPresenter)) { throw new ArgumentException(SR.Get(SRID.TemplateTargetTypeMismatch, "ItemsPresenter", templatedParent.GetType().Name)); } } #endregion Protected Methods } } // 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: ItemsPanelTemplate describes how ItemsPresenter creates the panel // that manages layout of containers for an ItemsControl. // // Specs: // //--------------------------------------------------------------------------- using System.ComponentModel; using System.Windows.Controls; using System.Windows.Markup; using System.Diagnostics; namespace System.Windows.Controls { ////// ItemsPanelTemplate describes how ItemsPresenter creates the panel /// that manages layout of containers for an ItemsControl. /// public class ItemsPanelTemplate : FrameworkTemplate { #region Constructors //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- ////// ItemsPanelTemplate Constructor /// public ItemsPanelTemplate() { } ////// ItemsPanelTemplate Constructor /// public ItemsPanelTemplate(FrameworkElementFactory root) { VisualTree = root; } #endregion Constructors #region Public Properties //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #endregion PublicProperties #region Internal Properties //-------------------------------------------------------------------- // // Internal Properties // //-------------------------------------------------------------------- // // TargetType for ItemsPanelTemplate. This is override is // so FrameworkTemplate can see this property. // internal override Type TargetTypeInternal { get { return DefaultTargetType; } } // Subclasses must provide a way for the parser to directly set the // target type. For ItemsPanelTemplate, this is not allowed. internal override void SetTargetTypeInternal(Type targetType) { throw new InvalidOperationException(SR.Get(SRID.TemplateNotTargetType)); } // Target type of ItemsPanelTemplate is ItemsPresenter static internal Type DefaultTargetType { get { return typeof(ItemsPresenter); } } #endregion Internal Properties #region Internal Methods //------------------------------------------------------------------- // // Internal Methods // //-------------------------------------------------------------------- // // ProcessTemplateBeforeSeal // // This is used in the case of templates defined with FEFs. For templates // in Baml (the typical case), see the OnApply override. // // 1. Verify that // a. root element is a Panel // 2. Set IsItemsHost = true // internal override void ProcessTemplateBeforeSeal() { FrameworkElementFactory root; if( HasContent ) { // This is a Baml-style template // Validate the root type (it must be a Panel) if (!typeof(Panel).IsAssignableFrom(OptimizedTemplateContent.RootType)) throw new InvalidOperationException(SR.Get(SRID.ItemsPanelNotAPanel, OptimizedTemplateContent.RootType)); // Set the IsItemsHost property on the root, via the template tables BamlNamedElementStartRecord bamlNamedElementStartRecord = OptimizedTemplateContent.UnsharedContent as BamlNamedElementStartRecord; SharedDp sharedDp = new SharedDp( Panel.IsItemsHostProperty, true, bamlNamedElementStartRecord.RuntimeName ); OptimizedTemplateContent.SharedProperties.Add( sharedDp ); } else if ((root = this.VisualTree) != null) { // This is a FEF-style template if (!typeof(Panel).IsAssignableFrom(root.Type)) throw new InvalidOperationException(SR.Get(SRID.ItemsPanelNotAPanel, root.Type)); root.SetValue(Panel.IsItemsHostProperty, true); } } #endregion Internal Methods #region Protected Methods //------------------------------------------------------------------- // // Protected Methods // //------------------------------------------------------------------- ////// Validate against the following rules /// 1. Must have a non-null feTemplatedParent /// 2. A ItemsPanelTemplate must be applied to a ContentPresenter /// protected override void ValidateTemplatedParent(FrameworkElement templatedParent) { // Must have a non-null feTemplatedParent if (templatedParent == null) { throw new ArgumentNullException("templatedParent"); } // A ItemsPanelTemplate must be applied to an ItemsPresenter if (!(templatedParent is ItemsPresenter)) { throw new ArgumentException(SR.Get(SRID.TemplateTargetTypeMismatch, "ItemsPresenter", templatedParent.GetType().Name)); } } #endregion Protected Methods } } // 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
- StatusBarPanel.cs
- DependencyObjectCodeDomSerializer.cs
- IImplicitResourceProvider.cs
- DataBindingExpressionBuilder.cs
- Bezier.cs
- WindowsImpersonationContext.cs
- DataSourceDesigner.cs
- SystemIPGlobalStatistics.cs
- ComponentResourceKeyConverter.cs
- ContentType.cs
- UserCancellationException.cs
- GridViewRowPresenterBase.cs
- OutputCacheProfile.cs
- GenericTypeParameterBuilder.cs
- EdmProperty.cs
- CodeVariableDeclarationStatement.cs
- ProcessHostServerConfig.cs
- StringPropertyBuilder.cs
- EventWaitHandle.cs
- CodeSnippetCompileUnit.cs
- DiscriminatorMap.cs
- CodeDomDesignerLoader.cs
- TableColumn.cs
- SqlDelegatedTransaction.cs
- D3DImage.cs
- MonthChangedEventArgs.cs
- FileLevelControlBuilderAttribute.cs
- DispatcherSynchronizationContext.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- TraceContextEventArgs.cs
- FolderLevelBuildProviderCollection.cs
- _UncName.cs
- TextRenderer.cs
- NameObjectCollectionBase.cs
- InputBuffer.cs
- GetPolicyDetailsRequest.cs
- XsltLoader.cs
- WindowAutomationPeer.cs
- Point.cs
- SafeHandle.cs
- CodeStatementCollection.cs
- XmlDataSourceNodeDescriptor.cs
- ActivitiesCollection.cs
- SchemaSetCompiler.cs
- RuntimeHandles.cs
- CodeSnippetTypeMember.cs
- SqlNode.cs
- ListCollectionView.cs
- DescendantQuery.cs
- VisualStates.cs
- ListDictionaryInternal.cs
- InvalidDataException.cs
- EntityKey.cs
- _BasicClient.cs
- EventQueueState.cs
- InputLanguageEventArgs.cs
- Screen.cs
- NotFiniteNumberException.cs
- MailAddressCollection.cs
- ContainerTracking.cs
- WithParamAction.cs
- SerializationStore.cs
- Lasso.cs
- Registry.cs
- EdmScalarPropertyAttribute.cs
- LiteralControl.cs
- WebServiceTypeData.cs
- Rect3DConverter.cs
- precedingquery.cs
- DbDeleteCommandTree.cs
- dataSvcMapFileLoader.cs
- TreeNodeCollection.cs
- HashCodeCombiner.cs
- EncryptRequest.cs
- LayoutEvent.cs
- EmbossBitmapEffect.cs
- TextEditorLists.cs
- ProcessThreadCollection.cs
- ExpressionBuilderContext.cs
- NativeMethods.cs
- MappingSource.cs
- NativeMethods.cs
- Types.cs
- DependentList.cs
- TargetInvocationException.cs
- GridLength.cs
- DbgCompiler.cs
- ArrangedElement.cs
- HeaderCollection.cs
- DataFormats.cs
- PkcsMisc.cs
- ImageSourceTypeConverter.cs
- EncryptedData.cs
- PreloadHost.cs
- ProfileSettings.cs
- XPathBinder.cs
- UnaryExpression.cs
- BitmapSizeOptions.cs
- StylusPoint.cs
- TextUtf8RawTextWriter.cs