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
- DefaultValueTypeConverter.cs
- HorizontalAlignConverter.cs
- BaseCodePageEncoding.cs
- Evidence.cs
- PropertyState.cs
- QueryPageSettingsEventArgs.cs
- BamlLocalizableResource.cs
- InstanceKey.cs
- control.ime.cs
- ViewStateModeByIdAttribute.cs
- HttpPostLocalhostServerProtocol.cs
- HandlerMappingMemo.cs
- RuntimeArgumentHandle.cs
- SmtpMail.cs
- LinearKeyFrames.cs
- DispatcherEventArgs.cs
- InputReportEventArgs.cs
- TypeUnloadedException.cs
- SettingsPropertyIsReadOnlyException.cs
- BidOverLoads.cs
- XmlRootAttribute.cs
- XPathEmptyIterator.cs
- DataGridViewAccessibleObject.cs
- ObjectQuery.cs
- XamlVector3DCollectionSerializer.cs
- InlineUIContainer.cs
- OdbcConnectionHandle.cs
- MetadataPropertyvalue.cs
- OneOfElement.cs
- ItemDragEvent.cs
- StrongNameKeyPair.cs
- HandlerBase.cs
- ViewService.cs
- TypeDescriptionProvider.cs
- XmlImplementation.cs
- TabControl.cs
- ModuleElement.cs
- QilXmlReader.cs
- MarkupCompilePass1.cs
- TracePayload.cs
- RSAPKCS1SignatureDeformatter.cs
- Application.cs
- DebugView.cs
- Metadata.cs
- ElementMarkupObject.cs
- RadioButton.cs
- GZipStream.cs
- CompiledELinqQueryState.cs
- PropertySourceInfo.cs
- FreezableDefaultValueFactory.cs
- SubstitutionDesigner.cs
- InputManager.cs
- FeatureSupport.cs
- TextTreeTextBlock.cs
- RelationshipConstraintValidator.cs
- FormsAuthenticationConfiguration.cs
- DigitShape.cs
- EntityConnectionStringBuilderItem.cs
- SignatureHelper.cs
- ListParagraph.cs
- FormsAuthenticationModule.cs
- ItemsPanelTemplate.cs
- ContainsRowNumberChecker.cs
- FontNameConverter.cs
- TriggerAction.cs
- PropertyNames.cs
- StateDesigner.CommentLayoutGlyph.cs
- WebBrowserDocumentCompletedEventHandler.cs
- Debugger.cs
- SurrogateSelector.cs
- FunctionQuery.cs
- ServiceManagerHandle.cs
- KeyboardDevice.cs
- RegistrationContext.cs
- InputLanguageCollection.cs
- Int32Storage.cs
- AutomationElement.cs
- DefaultParameterValueAttribute.cs
- PropertyCollection.cs
- SqlStream.cs
- DataGridViewButtonCell.cs
- sortedlist.cs
- Thread.cs
- _IPv4Address.cs
- SupportedAddressingMode.cs
- CodeCompileUnit.cs
- UshortList2.cs
- HttpListenerRequestUriBuilder.cs
- WebPartConnectionsEventArgs.cs
- FullTextState.cs
- AutoSizeComboBox.cs
- SingleKeyFrameCollection.cs
- DefaultPrintController.cs
- NamespaceCollection.cs
- DependencyObjectValidator.cs
- DependentList.cs
- DataGridHeaderBorder.cs
- X509CertificateCollection.cs
- LabelLiteral.cs
- OleDbParameter.cs