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
- NullableDecimalAverageAggregationOperator.cs
- SoapCodeExporter.cs
- _ListenerResponseStream.cs
- ToolStripCollectionEditor.cs
- InheritedPropertyChangedEventArgs.cs
- EditingContext.cs
- SqlServices.cs
- shaperfactoryquerycachekey.cs
- TaskFileService.cs
- DbProviderManifest.cs
- NonPrimarySelectionGlyph.cs
- ComboBox.cs
- XmlNotation.cs
- SwitchAttribute.cs
- SqlInfoMessageEvent.cs
- HtmlControlPersistable.cs
- CodeTypeDeclaration.cs
- NameSpaceEvent.cs
- SqlNodeAnnotation.cs
- ByteConverter.cs
- DataGridViewCellConverter.cs
- SubclassTypeValidatorAttribute.cs
- ActionFrame.cs
- CodeCatchClauseCollection.cs
- BufferedGraphics.cs
- CompilerInfo.cs
- TraceHwndHost.cs
- DataGridViewBand.cs
- ExceptionUtil.cs
- VSDExceptions.cs
- CultureTable.cs
- SortedDictionary.cs
- DBSchemaTable.cs
- QilInvokeLateBound.cs
- TdsParserSafeHandles.cs
- XsdDataContractImporter.cs
- RawStylusActions.cs
- DocumentSchemaValidator.cs
- SecurityRuntime.cs
- ReturnValue.cs
- unsafenativemethodstextservices.cs
- AnnotationMap.cs
- Int64.cs
- DataObjectSettingDataEventArgs.cs
- TypeHelpers.cs
- ButtonField.cs
- BaseParser.cs
- isolationinterop.cs
- controlskin.cs
- MessageHeaderException.cs
- CodeSnippetTypeMember.cs
- DoubleKeyFrameCollection.cs
- ZipIOExtraField.cs
- ComponentDispatcherThread.cs
- PKCS1MaskGenerationMethod.cs
- ServerValidateEventArgs.cs
- HttpResponseHeader.cs
- UshortList2.cs
- VectorCollection.cs
- XsltFunctions.cs
- ComponentResourceKeyConverter.cs
- ParameterBuilder.cs
- Documentation.cs
- CommandEventArgs.cs
- HttpPostServerProtocol.cs
- XmlSchemaComplexContentExtension.cs
- UnknownWrapper.cs
- SystemNetHelpers.cs
- AnnotationResourceCollection.cs
- FixedDocumentPaginator.cs
- EntityDataSourceWrapper.cs
- EventBuilder.cs
- DocumentGrid.cs
- PaintEvent.cs
- PartitionerStatic.cs
- WindowsIdentity.cs
- SrgsElement.cs
- ListChunk.cs
- Span.cs
- ExpandoObject.cs
- SqlDependencyListener.cs
- PrefixQName.cs
- ObjectTag.cs
- SerializationObjectManager.cs
- PersistenceTypeAttribute.cs
- DataQuery.cs
- TextEditorMouse.cs
- CharEnumerator.cs
- ExtensionSimplifierMarkupObject.cs
- WindowsBrush.cs
- DiscoveryClientRequestChannel.cs
- WebPartDeleteVerb.cs
- GridViewUpdateEventArgs.cs
- ObjectPersistData.cs
- SQLString.cs
- RectIndependentAnimationStorage.cs
- TextEmbeddedObject.cs
- DataSvcMapFile.cs
- SqlNotificationRequest.cs
- DiscoveryExceptionDictionary.cs