Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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) { Debug.Assert(!string.IsNullOrEmpty(displayMemberPath)); _displayMemberPath = displayMemberPath; } ////// 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; 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); text.SetBinding(TextBlock.TextProperty, binding); _clrNodeContentTemplate.VisualTree = text; _clrNodeContentTemplate.Seal(); } return _clrNodeContentTemplate; } } private string _displayMemberPath; 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
- ConnectionInterfaceCollection.cs
- RowToParametersTransformer.cs
- IntegerFacetDescriptionElement.cs
- BaseWebProxyFinder.cs
- HtmlSelect.cs
- TakeOrSkipQueryOperator.cs
- DataMember.cs
- XsltFunctions.cs
- TypeCollectionPropertyEditor.cs
- XslAst.cs
- SafeFindHandle.cs
- Library.cs
- AssertSection.cs
- CheckBoxStandardAdapter.cs
- NetPeerTcpBindingCollectionElement.cs
- AttributeCollection.cs
- FileIOPermission.cs
- DataStreamFromComStream.cs
- ChainOfResponsibility.cs
- DynamicResourceExtensionConverter.cs
- MultiSelectRootGridEntry.cs
- BroadcastEventHelper.cs
- RemotingClientProxy.cs
- MostlySingletonList.cs
- ThemeableAttribute.cs
- ErrorTolerantObjectWriter.cs
- SmtpClient.cs
- ISessionStateStore.cs
- FixedBufferAttribute.cs
- XsdValidatingReader.cs
- KerberosSecurityTokenAuthenticator.cs
- ComponentChangedEvent.cs
- RecordManager.cs
- ReflectionUtil.cs
- XmlDictionaryWriter.cs
- HMACSHA512.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- DataGridViewSelectedCellCollection.cs
- DataKeyCollection.cs
- IChannel.cs
- XdrBuilder.cs
- InProcStateClientManager.cs
- NavigationPropertyEmitter.cs
- MsmqPoisonMessageException.cs
- DesignTimeSiteMapProvider.cs
- Parser.cs
- SessionIDManager.cs
- DataGridParentRows.cs
- BlurBitmapEffect.cs
- MetabaseServerConfig.cs
- ProjectionCamera.cs
- XmlILOptimizerVisitor.cs
- SqlNotificationEventArgs.cs
- PartialList.cs
- CancellationToken.cs
- NetworkInformationException.cs
- PersonalizablePropertyEntry.cs
- SharedConnectionWorkflowTransactionService.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- RegexFCD.cs
- ConsumerConnectionPoint.cs
- SkewTransform.cs
- XmlDictionary.cs
- MethodToken.cs
- SymLanguageVendor.cs
- XmlTextWriter.cs
- ControlCachePolicy.cs
- SerializerWriterEventHandlers.cs
- AsyncPostBackTrigger.cs
- OleDbFactory.cs
- Pens.cs
- FacetValues.cs
- CrossAppDomainChannel.cs
- safePerfProviderHandle.cs
- SessionPageStatePersister.cs
- Item.cs
- Events.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- PersonalizationAdministration.cs
- PriorityChain.cs
- TimelineGroup.cs
- CustomTypeDescriptor.cs
- CompiledQuery.cs
- CopyCodeAction.cs
- FormsAuthenticationEventArgs.cs
- QuaternionAnimationBase.cs
- TemplatedAdorner.cs
- oledbconnectionstring.cs
- ChtmlTextWriter.cs
- WebPartConnectionsCloseVerb.cs
- XmlBinaryReader.cs
- CodeVariableDeclarationStatement.cs
- TokenBasedSetEnumerator.cs
- Int32CAMarshaler.cs
- BooleanConverter.cs
- CookieProtection.cs
- WmlLabelAdapter.cs
- Function.cs
- FixUpCollection.cs
- XmlSchemaObject.cs