Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / Data / DisplayMemberTemplateSelector.cs / 1 / DisplayMemberTemplateSelector.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Defines DisplayMemberTemplateSelector class. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using MS.Internal; namespace MS.Internal.Data { // Selects template appropriate for CLR/XML item in order to // display string property at DisplayMemberPath on the item. internal sealed class DisplayMemberTemplateSelector : DataTemplateSelector { ////// Constructor /// /// path to the member to display public DisplayMemberTemplateSelector(string displayMemberPath, string stringFormat) { Debug.Assert(!(String.IsNullOrEmpty(displayMemberPath) && String.IsNullOrEmpty(stringFormat))); _displayMemberPath = displayMemberPath; _stringFormat = stringFormat; } ////// Override this method to return an app specific /// The data content /// The container in which the content is to be displayed ///. /// a app specific template to apply. public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (XmlHelper.IsXmlNode(item)) { if (_xmlNodeContentTemplate == null) { _xmlNodeContentTemplate = new DataTemplate(); FrameworkElementFactory text = ContentPresenter.CreateTextBlockFactory(); Binding binding = new Binding(); binding.XPath = _displayMemberPath; binding.StringFormat = _stringFormat; text.SetBinding(TextBlock.TextProperty, binding); _xmlNodeContentTemplate.VisualTree = text; _xmlNodeContentTemplate.Seal(); } return _xmlNodeContentTemplate; } else { if (_clrNodeContentTemplate == null) { _clrNodeContentTemplate = new DataTemplate(); FrameworkElementFactory text = ContentPresenter.CreateTextBlockFactory(); Binding binding = new Binding(); binding.Path = new PropertyPath(_displayMemberPath); binding.StringFormat = _stringFormat; text.SetBinding(TextBlock.TextProperty, binding); _clrNodeContentTemplate.VisualTree = text; _clrNodeContentTemplate.Seal(); } return _clrNodeContentTemplate; } } private string _displayMemberPath; private string _stringFormat; private DataTemplate _xmlNodeContentTemplate; private DataTemplate _clrNodeContentTemplate; } } // 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: Defines DisplayMemberTemplateSelector class. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using MS.Internal; namespace MS.Internal.Data { // Selects template appropriate for CLR/XML item in order to // display string property at DisplayMemberPath on the item. internal sealed class DisplayMemberTemplateSelector : DataTemplateSelector { ////// Constructor /// /// path to the member to display public DisplayMemberTemplateSelector(string displayMemberPath, string stringFormat) { Debug.Assert(!(String.IsNullOrEmpty(displayMemberPath) && String.IsNullOrEmpty(stringFormat))); _displayMemberPath = displayMemberPath; _stringFormat = stringFormat; } ////// Override this method to return an app specific /// The data content /// The container in which the content is to be displayed ///. /// a app specific template to apply. public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (XmlHelper.IsXmlNode(item)) { if (_xmlNodeContentTemplate == null) { _xmlNodeContentTemplate = new DataTemplate(); FrameworkElementFactory text = ContentPresenter.CreateTextBlockFactory(); Binding binding = new Binding(); binding.XPath = _displayMemberPath; binding.StringFormat = _stringFormat; text.SetBinding(TextBlock.TextProperty, binding); _xmlNodeContentTemplate.VisualTree = text; _xmlNodeContentTemplate.Seal(); } return _xmlNodeContentTemplate; } else { if (_clrNodeContentTemplate == null) { _clrNodeContentTemplate = new DataTemplate(); FrameworkElementFactory text = ContentPresenter.CreateTextBlockFactory(); Binding binding = new Binding(); binding.Path = new PropertyPath(_displayMemberPath); binding.StringFormat = _stringFormat; text.SetBinding(TextBlock.TextProperty, binding); _clrNodeContentTemplate.VisualTree = text; _clrNodeContentTemplate.Seal(); } return _clrNodeContentTemplate; } } private string _displayMemberPath; private string _stringFormat; private DataTemplate _xmlNodeContentTemplate; private DataTemplate _clrNodeContentTemplate; } } // 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
- OutputCacheSection.cs
- DetailsViewModeEventArgs.cs
- TrustManagerPromptUI.cs
- PrintPreviewDialog.cs
- SystemException.cs
- HttpContext.cs
- QueryUtil.cs
- BezierSegment.cs
- SecurityState.cs
- Facet.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- AmbientLight.cs
- CounterCreationDataConverter.cs
- RealizedColumnsBlock.cs
- ResourceDescriptionAttribute.cs
- TypeBuilderInstantiation.cs
- CacheSection.cs
- ColumnResizeUndoUnit.cs
- HashCodeCombiner.cs
- ResourceSet.cs
- InstalledFontCollection.cs
- WebPartDisplayModeEventArgs.cs
- WebDisplayNameAttribute.cs
- WindowsTokenRoleProvider.cs
- BitmapSourceSafeMILHandle.cs
- WindowsSecurityToken.cs
- ScrollChangedEventArgs.cs
- WebPageTraceListener.cs
- FixedSOMTable.cs
- SevenBitStream.cs
- InfoCardListRequest.cs
- AppearanceEditorPart.cs
- Soap12FormatExtensions.cs
- LocationUpdates.cs
- _SSPIWrapper.cs
- DbProviderManifest.cs
- X509Utils.cs
- VirtualizedCellInfoCollection.cs
- StandardBindingElement.cs
- SerializerDescriptor.cs
- IsolatedStorageException.cs
- SafeNativeMethods.cs
- COM2FontConverter.cs
- XmlLangPropertyAttribute.cs
- SeparatorAutomationPeer.cs
- PageClientProxyGenerator.cs
- ModelPropertyCollectionImpl.cs
- StorageComplexPropertyMapping.cs
- KeyPressEvent.cs
- IDictionary.cs
- TableColumn.cs
- ManifestResourceInfo.cs
- SoapInteropTypes.cs
- PipelineDeploymentState.cs
- RawAppCommandInputReport.cs
- MouseEvent.cs
- RegularExpressionValidator.cs
- DataGridTextColumn.cs
- DatePickerAutomationPeer.cs
- OperationInvokerBehavior.cs
- DataGridViewAutoSizeModeEventArgs.cs
- EmptyEnumerator.cs
- DrawingImage.cs
- ReliabilityContractAttribute.cs
- ParseHttpDate.cs
- StringOutput.cs
- Vector3D.cs
- TextEndOfSegment.cs
- PrimitiveCodeDomSerializer.cs
- RelationshipWrapper.cs
- HttpCookiesSection.cs
- tabpagecollectioneditor.cs
- ObjectKeyFrameCollection.cs
- JumpTask.cs
- SplitterCancelEvent.cs
- RtfFormatStack.cs
- DesignerDataStoredProcedure.cs
- RootProjectionNode.cs
- CodeEventReferenceExpression.cs
- FakeModelPropertyImpl.cs
- ConnectionProviderAttribute.cs
- UnsafeNativeMethods.cs
- MailMessageEventArgs.cs
- ElementAction.cs
- DataGridPageChangedEventArgs.cs
- FileUtil.cs
- PreviewPrintController.cs
- ConfigErrorGlyph.cs
- XmlName.cs
- HideDisabledControlAdapter.cs
- SafeFindHandle.cs
- UnmanagedMemoryStream.cs
- xml.cs
- SiteMapDataSourceView.cs
- CellPartitioner.cs
- InternalPermissions.cs
- Transform.cs
- DatePicker.cs
- SynchronousReceiveBehavior.cs
- XmlComplianceUtil.cs