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
- CacheHelper.cs
- wgx_commands.cs
- WebPartVerb.cs
- DataGridViewCellParsingEventArgs.cs
- xml.cs
- DesignerToolStripControlHost.cs
- XPathDocumentNavigator.cs
- UriScheme.cs
- MaskedTextBox.cs
- ObjectListCommandCollection.cs
- DragCompletedEventArgs.cs
- MsmqBindingBase.cs
- WebRequestModuleElement.cs
- DataListItemEventArgs.cs
- RuntimeWrappedException.cs
- GeometryDrawing.cs
- GlyphInfoList.cs
- DataGridViewCellPaintingEventArgs.cs
- ReadOnlyHierarchicalDataSource.cs
- ObjectQuery_EntitySqlExtensions.cs
- TypeForwardedToAttribute.cs
- RequestQueue.cs
- OpenTypeLayout.cs
- XNodeSchemaApplier.cs
- ContextMenuStrip.cs
- DateBoldEvent.cs
- LayoutDump.cs
- IPHostEntry.cs
- SmtpReplyReader.cs
- ResourceCategoryAttribute.cs
- ContainerActivationHelper.cs
- CacheMemory.cs
- X509ScopedServiceCertificateElement.cs
- DataGridTextColumn.cs
- LazyTextWriterCreator.cs
- Propagator.JoinPropagator.cs
- WithParamAction.cs
- util.cs
- DataListCommandEventArgs.cs
- GlyphElement.cs
- MultiSelectRootGridEntry.cs
- HostSecurityManager.cs
- DBSchemaTable.cs
- X509Certificate2Collection.cs
- ValidateNames.cs
- ValidationSummary.cs
- FontStyleConverter.cs
- Binding.cs
- CustomCredentialPolicy.cs
- ImageFormat.cs
- AdapterDictionary.cs
- ToolBarTray.cs
- Geometry3D.cs
- SqlCommandSet.cs
- Content.cs
- Byte.cs
- DiscreteKeyFrames.cs
- _HelperAsyncResults.cs
- BaseComponentEditor.cs
- Model3D.cs
- ClientSettingsStore.cs
- DataGridTextBox.cs
- CryptoApi.cs
- GreenMethods.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ObjectListDataBindEventArgs.cs
- ServiceNotStartedException.cs
- FixedDocument.cs
- DataRecordInfo.cs
- XamlDesignerSerializationManager.cs
- SecurityException.cs
- InternalConfigConfigurationFactory.cs
- SafeFileMappingHandle.cs
- NativeMethodsOther.cs
- WinHttpWebProxyFinder.cs
- SelectionEditor.cs
- ValidationError.cs
- ImplicitInputBrush.cs
- _ListenerAsyncResult.cs
- Predicate.cs
- TagNameToTypeMapper.cs
- ScrollEventArgs.cs
- RtfControlWordInfo.cs
- Size.cs
- RequestTimeoutManager.cs
- TextBounds.cs
- FolderLevelBuildProvider.cs
- ResourceProviderFactory.cs
- ComponentResourceKeyConverter.cs
- ProofTokenCryptoHandle.cs
- XmlWriter.cs
- PerformanceCountersElement.cs
- IsolatedStorageFile.cs
- SerialPinChanges.cs
- DbProviderFactory.cs
- ExceptQueryOperator.cs
- Identity.cs
- StringFormat.cs
- BindingListCollectionView.cs
- MenuItemStyleCollection.cs