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
- DataGridViewRowPrePaintEventArgs.cs
- Link.cs
- SimpleFieldTemplateFactory.cs
- DoubleAnimationUsingPath.cs
- StreamedFramingRequestChannel.cs
- TextParagraphCache.cs
- Processor.cs
- BaseCodeDomTreeGenerator.cs
- TemplateEditingFrame.cs
- MetadataItemEmitter.cs
- HostedBindingBehavior.cs
- TypeInitializationException.cs
- ClientSettingsSection.cs
- SmtpNegotiateAuthenticationModule.cs
- PaperSize.cs
- HostExecutionContextManager.cs
- WorkflowMarkupSerializationManager.cs
- RoleService.cs
- DtdParser.cs
- MsmqProcessProtocolHandler.cs
- PostBackOptions.cs
- FormCollection.cs
- DeclaredTypeValidator.cs
- ToolStripItemEventArgs.cs
- TextCompositionEventArgs.cs
- ResourcesGenerator.cs
- ListBindableAttribute.cs
- Polygon.cs
- XhtmlConformanceSection.cs
- TemplateFactory.cs
- InheritablePropertyChangeInfo.cs
- StatusBar.cs
- GenericIdentity.cs
- CapabilitiesUse.cs
- SplineKeyFrames.cs
- XmlConvert.cs
- x509utils.cs
- WebPartDisplayModeEventArgs.cs
- ResourceProperty.cs
- RequestUriProcessor.cs
- XmlQuerySequence.cs
- XmlSchemas.cs
- View.cs
- CatalogZoneBase.cs
- XhtmlBasicFormAdapter.cs
- AnimationStorage.cs
- _AcceptOverlappedAsyncResult.cs
- SQLDecimalStorage.cs
- Freezable.cs
- CriticalExceptions.cs
- XmlChoiceIdentifierAttribute.cs
- ViewPort3D.cs
- WebPartCancelEventArgs.cs
- ScopeElement.cs
- RadioButtonFlatAdapter.cs
- hresults.cs
- Win32NamedPipes.cs
- AbstractSvcMapFileLoader.cs
- TextProperties.cs
- ColumnPropertiesGroup.cs
- CellConstantDomain.cs
- Int16.cs
- StringArrayConverter.cs
- Converter.cs
- BuildDependencySet.cs
- TemplateControlCodeDomTreeGenerator.cs
- DefinitionBase.cs
- QilList.cs
- WebReferencesBuildProvider.cs
- WindowsProgressbar.cs
- WebPartConnectionCollection.cs
- ComAdminInterfaces.cs
- SkipQueryOptionExpression.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- FontDifferentiator.cs
- RequestQueryParser.cs
- TagMapInfo.cs
- BitmapEffect.cs
- SqlParameterizer.cs
- ReadWriteObjectLock.cs
- TypeDependencyAttribute.cs
- BaseCodePageEncoding.cs
- DataGridPagerStyle.cs
- ColumnWidthChangingEvent.cs
- PathSegmentCollection.cs
- Table.cs
- BackStopAuthenticationModule.cs
- DocumentViewerHelper.cs
- ApplicationInfo.cs
- Metadata.cs
- ColorTranslator.cs
- GatewayIPAddressInformationCollection.cs
- KeyInstance.cs
- MenuItemAutomationPeer.cs
- SetUserPreferenceRequest.cs
- NullableDoubleSumAggregationOperator.cs
- Action.cs
- UpdateTracker.cs
- ListBindingHelper.cs
- RtfToXamlLexer.cs