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
- AssemblyHash.cs
- DataControlButton.cs
- TdsParser.cs
- Keywords.cs
- ImmutableCollection.cs
- ItemCollection.cs
- WebBrowserNavigatedEventHandler.cs
- XmlSchemaChoice.cs
- LineVisual.cs
- ActivityCollectionMarkupSerializer.cs
- ListViewDesigner.cs
- Screen.cs
- WebPartUtil.cs
- XhtmlMobileTextWriter.cs
- ScrollProviderWrapper.cs
- Button.cs
- FilteredAttributeCollection.cs
- ToolStripScrollButton.cs
- SatelliteContractVersionAttribute.cs
- SortedDictionary.cs
- SystemTcpStatistics.cs
- X509SecurityTokenProvider.cs
- DesignerWidgets.cs
- WebPartEditVerb.cs
- XpsColorContext.cs
- MergablePropertyAttribute.cs
- MailMessageEventArgs.cs
- SaveFileDialogDesigner.cs
- ResourcesChangeInfo.cs
- SwitchAttribute.cs
- MemberProjectionIndex.cs
- ConsoleKeyInfo.cs
- ForceCopyBuildProvider.cs
- XmlTypeAttribute.cs
- TypeToStringValueConverter.cs
- NestedContainer.cs
- FileAuthorizationModule.cs
- XPathArrayIterator.cs
- MasterPageBuildProvider.cs
- BasicDesignerLoader.cs
- RijndaelManagedTransform.cs
- PrintingPermission.cs
- Enlistment.cs
- ConstraintCollection.cs
- IconBitmapDecoder.cs
- SqlFlattener.cs
- StaticResourceExtension.cs
- BigInt.cs
- Clock.cs
- Storyboard.cs
- TableRow.cs
- CaseCqlBlock.cs
- BindingSourceDesigner.cs
- RelativeSource.cs
- DataKey.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Expressions.cs
- MarkupWriter.cs
- SystemUdpStatistics.cs
- _HeaderInfoTable.cs
- TextCompositionEventArgs.cs
- ZeroOpNode.cs
- ILGenerator.cs
- DesignerHost.cs
- XsltOutput.cs
- InfoCardServiceInstallComponent.cs
- QueryExpression.cs
- FixedSOMLineRanges.cs
- SessionEndingEventArgs.cs
- FileDialogCustomPlace.cs
- XmlSchemaSimpleContent.cs
- TransportSecurityHelpers.cs
- WebServiceData.cs
- ObjectQueryState.cs
- InternalConfigSettingsFactory.cs
- SpecularMaterial.cs
- BufferModesCollection.cs
- WebPart.cs
- ReachDocumentPageSerializerAsync.cs
- SchemaCollectionCompiler.cs
- TransformProviderWrapper.cs
- BindingExpressionUncommonField.cs
- Encoder.cs
- DrawingAttributesDefaultValueFactory.cs
- Screen.cs
- basecomparevalidator.cs
- DataGridAddNewRow.cs
- IRCollection.cs
- DataColumnCollection.cs
- CodePageUtils.cs
- ConfigurationLocation.cs
- IncrementalReadDecoders.cs
- FilterInvalidBodyAccessException.cs
- TraceLog.cs
- BindingManagerDataErrorEventArgs.cs
- WithParamAction.cs
- ErrorFormatter.cs
- JavaScriptSerializer.cs
- DataReaderContainer.cs
- MethodExpr.cs