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
- ProtocolsConfigurationHandler.cs
- WhitespaceRuleLookup.cs
- rsa.cs
- RecommendedAsConfigurableAttribute.cs
- DropDownList.cs
- TrackingParameters.cs
- ZipIORawDataFileBlock.cs
- QilXmlReader.cs
- BuildDependencySet.cs
- SrgsElementFactory.cs
- EmbeddedMailObjectsCollection.cs
- EmptyEnumerator.cs
- EditorAttribute.cs
- RawStylusActions.cs
- SafeRightsManagementPubHandle.cs
- coordinator.cs
- NetworkInterface.cs
- QilGenerator.cs
- AssemblyAttributesGoHere.cs
- HtmlContainerControl.cs
- HtmlLiteralTextAdapter.cs
- ItemChangedEventArgs.cs
- COM2PictureConverter.cs
- IPipelineRuntime.cs
- ComplexBindingPropertiesAttribute.cs
- CodeNamespaceImport.cs
- ActivityExecutionContextCollection.cs
- SchemaContext.cs
- ScheduleChanges.cs
- CodeBlockBuilder.cs
- PublishLicense.cs
- SafeNativeMethods.cs
- CreateUserWizard.cs
- MailHeaderInfo.cs
- CompilationUnit.cs
- TagPrefixInfo.cs
- SoapSchemaImporter.cs
- Pen.cs
- XmlMembersMapping.cs
- NativeMethods.cs
- TextEditorSpelling.cs
- Application.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- TargetControlTypeCache.cs
- DataGridViewButtonColumn.cs
- DynamicILGenerator.cs
- EnumValAlphaComparer.cs
- XmlName.cs
- MsmqTransportReceiveParameters.cs
- JoinElimination.cs
- TabPanel.cs
- GridViewUpdateEventArgs.cs
- ScrollItemPattern.cs
- LayoutTableCell.cs
- TabRenderer.cs
- Composition.cs
- EventRecord.cs
- InnerItemCollectionView.cs
- HtmlShim.cs
- TypeSystemHelpers.cs
- InfoCardKeyedHashAlgorithm.cs
- GeneratedContractType.cs
- OleDbConnectionFactory.cs
- InheritablePropertyChangeInfo.cs
- StringArrayConverter.cs
- MetafileHeader.cs
- SupportingTokenSpecification.cs
- MouseCaptureWithinProperty.cs
- ProviderConnectionPointCollection.cs
- ExternalException.cs
- NetTcpBindingCollectionElement.cs
- DataGridViewUtilities.cs
- RuntimeHandles.cs
- KeyFrames.cs
- ScriptModule.cs
- SessionStateContainer.cs
- AsyncContentLoadedEventArgs.cs
- ProviderSettingsCollection.cs
- CompareInfo.cs
- RadioButton.cs
- ToolStripGripRenderEventArgs.cs
- grammarelement.cs
- PassportIdentity.cs
- GiveFeedbackEventArgs.cs
- MouseCaptureWithinProperty.cs
- AvTraceFormat.cs
- SendMailErrorEventArgs.cs
- AuthenticationModuleElementCollection.cs
- MailWebEventProvider.cs
- TitleStyle.cs
- MiniCustomAttributeInfo.cs
- GB18030Encoding.cs
- Pkcs7Recipient.cs
- NCryptNative.cs
- XamlPoint3DCollectionSerializer.cs
- WsatEtwTraceListener.cs
- TextRange.cs
- WrapPanel.cs
- GridItem.cs
- XmlException.cs