Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Data / DisplayMemberTemplateSelector.cs / 1305600 / 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 (AssemblyHelper.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
- DynamicQueryableWrapper.cs
- CalendarDay.cs
- HybridDictionary.cs
- ComAdminInterfaces.cs
- TreeView.cs
- SafeEventLogWriteHandle.cs
- GridViewColumnCollection.cs
- MultiAsyncResult.cs
- ReverseInheritProperty.cs
- RegionData.cs
- PolyLineSegment.cs
- FrameworkElementFactory.cs
- XmlSerializerVersionAttribute.cs
- OleDbReferenceCollection.cs
- SessionSwitchEventArgs.cs
- InputReferenceExpression.cs
- UriSchemeKeyedCollection.cs
- DesignerObjectListAdapter.cs
- SystemTcpStatistics.cs
- PreservationFileWriter.cs
- RepeaterCommandEventArgs.cs
- DataControlFieldCollection.cs
- EmptyQuery.cs
- RequestCachingSection.cs
- OletxTransactionManager.cs
- XmlTextReader.cs
- Constant.cs
- shaper.cs
- FrameworkContextData.cs
- ColumnMapProcessor.cs
- GiveFeedbackEventArgs.cs
- XamlWriter.cs
- Context.cs
- WindowsAuthenticationModule.cs
- EntityCommand.cs
- If.cs
- DataContractJsonSerializerOperationBehavior.cs
- Material.cs
- RequestCachePolicyConverter.cs
- EdmComplexPropertyAttribute.cs
- exports.cs
- ShaderEffect.cs
- PartialTrustVisibleAssembliesSection.cs
- AlphaSortedEnumConverter.cs
- ArgumentNullException.cs
- HwndProxyElementProvider.cs
- ConditionalBranch.cs
- AsyncCompletedEventArgs.cs
- FastEncoder.cs
- WindowsComboBox.cs
- TextFormatter.cs
- DataPagerFieldItem.cs
- MenuItemBinding.cs
- infer.cs
- StorageInfo.cs
- HttpCacheVary.cs
- RuleSetDialog.cs
- HitTestParameters.cs
- ConfigurationSectionHelper.cs
- Guid.cs
- EntryPointNotFoundException.cs
- Semaphore.cs
- ForeignKeyFactory.cs
- basenumberconverter.cs
- TabControl.cs
- SiteMapNodeItem.cs
- RSAOAEPKeyExchangeFormatter.cs
- TagPrefixCollection.cs
- StructuredTypeEmitter.cs
- TraceUtility.cs
- EnglishPluralizationService.cs
- LayoutDump.cs
- QueryCacheManager.cs
- EditBehavior.cs
- RuntimeIdentifierPropertyAttribute.cs
- MenuEventArgs.cs
- SaveFileDialog.cs
- ExtensionQuery.cs
- Transform3D.cs
- ProcessModelSection.cs
- DataSysAttribute.cs
- MultiTargetingUtil.cs
- ProfileManager.cs
- TransactionManagerProxy.cs
- SafeArrayTypeMismatchException.cs
- MergablePropertyAttribute.cs
- SecurityToken.cs
- FixedSOMTable.cs
- TraceListeners.cs
- ResourceContainer.cs
- XmlSerializerAssemblyAttribute.cs
- ProfileService.cs
- NativeMethods.cs
- ViewValidator.cs
- RegistryDataKey.cs
- OrderByQueryOptionExpression.cs
- BinHexEncoder.cs
- XamlParser.cs
- RemoveStoryboard.cs
- MultipleViewProviderWrapper.cs