Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / DataTemplate.cs / 1 / DataTemplate.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: DataTemplate describes how to display a single data item. // // Specs: [....]/coreui/Specs%20%20Property%20Engine/Styling%20Revisited.doc // //--------------------------------------------------------------------------- using System.ComponentModel; using System.Windows.Controls; using System.Windows.Markup; namespace System.Windows { ////// DataTemplate describes how to display a single data item. /// public class DataTemplate : FrameworkTemplate { #region Constructors //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- ////// DataTemplate Constructor /// public DataTemplate() { } ////// DataTemplate Constructor /// public DataTemplate(object dataType) { Exception ex = TemplateKey.ValidateDataType(dataType, "dataType"); if (ex != null) throw ex; _dataType = dataType; } #endregion Constructors #region Public Properties //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- ////// DataType for this DataTemplate. If the template is intended /// for object data, this is the Type of the data. If the /// template is intended for XML data, this is the tag name /// of the data (i.e. a string). /// [DefaultValue(null)] public object DataType { get { return _dataType; } set { Exception ex = TemplateKey.ValidateDataType(value, "value"); if (ex != null) throw ex; CheckSealed(); _dataType = value; } } ////// Collection of Triggers /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [DependsOn("VisualTree")] public TriggerCollection Triggers { get { if (_triggers == null) { _triggers = new TriggerCollection(); // If the template has been sealed prior to this the newly // created TriggerCollection also needs to be sealed if (IsSealed) { _triggers.Seal(); } } return _triggers; } } #endregion PublicProperties #region Internal Properties //-------------------------------------------------------------------- // // Internal Properties // //-------------------------------------------------------------------- // // TargetType for DataTemplate. 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 DataTemplate, this is not allowed. internal override void SetTargetTypeInternal(Type targetType) { throw new InvalidOperationException(SR.Get(SRID.TemplateNotTargetType)); } // // DataType for DataTemplate. This is override is // so FrameworkTemplate can see this property. // internal override object DataTypeInternal { get { return DataType; } } // // Collection of Triggers for a DataTemplate. This is // override is so FrameworkTemplate can see this property. // internal override TriggerCollection TriggersInternal { get { return Triggers; } } // Target type of DataTrigger is ContentPresenter static internal Type DefaultTargetType { get { return typeof(ContentPresenter); } } #endregion Internal Properties #region Protected Methods //------------------------------------------------------------------- // // Protected Methods // //-------------------------------------------------------------------- ////// Validate against the following rules /// 1. Must have a non-null feTemplatedParent /// 2. A DataTemplate 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 DataTemplate must be applied to a ContentPresenter if (!(templatedParent is ContentPresenter)) { throw new ArgumentException(SR.Get(SRID.TemplateTargetTypeMismatch, "ContentPresenter", templatedParent.GetType().Name)); } } #endregion Protected Methods #region Data private object _dataType; private TriggerCollection _triggers; #endregion Data } } // 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
- WebBrowserUriTypeConverter.cs
- XmlSerializableReader.cs
- DesignerLabelAdapter.cs
- FormsAuthenticationEventArgs.cs
- SHA1CryptoServiceProvider.cs
- BasicHttpSecurityMode.cs
- SqlError.cs
- Point4D.cs
- GenericWebPart.cs
- UnsignedPublishLicense.cs
- WindowsListViewSubItem.cs
- StreamAsIStream.cs
- StaticResourceExtension.cs
- DBCSCodePageEncoding.cs
- IndexExpression.cs
- StreamGeometry.cs
- SystemIcmpV6Statistics.cs
- ValuePatternIdentifiers.cs
- ConstrainedDataObject.cs
- OleDbRowUpdatedEvent.cs
- ViewCellSlot.cs
- Visitors.cs
- FontStyle.cs
- NameObjectCollectionBase.cs
- ResourceReferenceExpressionConverter.cs
- PropertyChangingEventArgs.cs
- BinaryCommonClasses.cs
- ScrollEventArgs.cs
- OdbcParameterCollection.cs
- DataServiceProviderWrapper.cs
- WindowsMenu.cs
- FontFamilyValueSerializer.cs
- EntityCommand.cs
- EntityDataSourceEntitySetNameItem.cs
- StandardOleMarshalObject.cs
- EqualityArray.cs
- ObjectMemberMapping.cs
- DeadCharTextComposition.cs
- MarginsConverter.cs
- RtfToXamlReader.cs
- ColumnResizeUndoUnit.cs
- XmlSequenceWriter.cs
- MdiWindowListStrip.cs
- RequestStatusBarUpdateEventArgs.cs
- CodeAccessPermission.cs
- ConfigXmlElement.cs
- Material.cs
- CodeConditionStatement.cs
- DesigntimeLicenseContext.cs
- ToolStripContentPanelRenderEventArgs.cs
- ConfigXmlWhitespace.cs
- XmlSchemaSearchPattern.cs
- SoapIgnoreAttribute.cs
- MenuItem.cs
- RunInstallerAttribute.cs
- EventToken.cs
- TextView.cs
- OracleString.cs
- MissingMemberException.cs
- FacetEnabledSchemaElement.cs
- EndEvent.cs
- SerializationHelper.cs
- WindowsListViewGroupHelper.cs
- InternalSafeNativeMethods.cs
- SmtpNegotiateAuthenticationModule.cs
- TextRunCacheImp.cs
- XmlAttribute.cs
- StorageEntitySetMapping.cs
- BufferedWebEventProvider.cs
- JsonFormatReaderGenerator.cs
- ListChunk.cs
- MissingMethodException.cs
- GatewayDefinition.cs
- RectConverter.cs
- Pen.cs
- BeginEvent.cs
- CodeTypeParameter.cs
- Lock.cs
- WebUtil.cs
- SigningCredentials.cs
- InstancePersistenceCommand.cs
- OrderedDictionaryStateHelper.cs
- ItemsPresenter.cs
- BoolExpressionVisitors.cs
- SafeThemeHandle.cs
- TagPrefixInfo.cs
- _NetRes.cs
- DashStyle.cs
- StoreUtilities.cs
- XmlToDatasetMap.cs
- DependencyPropertyConverter.cs
- Internal.cs
- X509Certificate2.cs
- StatusBar.cs
- log.cs
- SyncMethodInvoker.cs
- IsolatedStorageFileStream.cs
- AxHostDesigner.cs
- TypeListConverter.cs
- SchemaMapping.cs