Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / DynamicResourceExtension.cs / 1 / DynamicResourceExtension.cs
/****************************************************************************\ * * File: DynamicResourceExtension.cs * * Class for Xaml markup extension for static resource references. * * Copyright (C) 2004 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.ComponentModel; using System.Windows; using System.Windows.Markup; using System.Reflection; using MS.Internal; // Helper namespace System.Windows { ////// Class for Xaml markup extension for static resource references. /// [TypeConverter(typeof(DynamicResourceExtensionConverter))] [MarkupExtensionReturnType(typeof(object))] public class DynamicResourceExtension : MarkupExtension { ////// Constructor that takes no parameters /// public DynamicResourceExtension() { } ////// Constructor that takes the resource key that this is a static reference to. /// public DynamicResourceExtension( object resourceKey) { if (resourceKey == null) { throw new ArgumentNullException("resourceKey"); } _resourceKey = resourceKey; } ////// Return an object that should be set on the targetObject's targetProperty /// for this markup extension. For DynamicResourceExtension, this is the object found in /// a resource dictionary in the current parent chain that is keyed by ResourceKey /// ////// The object to set on this property. /// public override object ProvideValue(IServiceProvider serviceProvider) { if (ResourceKey == null) { throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionResourceKey)); } if (serviceProvider != null) { IProvideValueTarget provideValueTarget = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget; // DynamicResourceExtensions are not allowed On CLR props except for Setter,Trigger,Condition (bugs 1183373,1572537) DependencyObject targetDependencyObject; DependencyProperty targetDependencyProperty; Helper.CheckCanReceiveMarkupExtension(this, provideValueTarget, out targetDependencyObject, out targetDependencyProperty); } return new ResourceReferenceExpression(ResourceKey); } ////// The key in a Resource Dictionary used to find the object refered to by this /// Markup Extension. /// [ConstructorArgument("resourceKey")] // Uses an instance descriptor public object ResourceKey { get { return _resourceKey; } set { if (value == null) { throw new ArgumentNullException("value"); } _resourceKey = value; } } private object _resourceKey; } } // 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
- DataGridTableStyleMappingNameEditor.cs
- InheritanceContextHelper.cs
- FileSecurity.cs
- AppSettingsReader.cs
- SynchronizedDispatch.cs
- PerformanceCounterScope.cs
- RedirectionProxy.cs
- WarningException.cs
- XmlAttributeOverrides.cs
- Size3D.cs
- ContextProperty.cs
- DataControlReferenceCollection.cs
- ImageCreator.cs
- _SpnDictionary.cs
- EdmItemCollection.cs
- DispatcherTimer.cs
- Int32KeyFrameCollection.cs
- ConfigsHelper.cs
- FunctionNode.cs
- ComplexBindingPropertiesAttribute.cs
- MessageQueue.cs
- ConfigurationManager.cs
- VersionPair.cs
- EntitySetDataBindingList.cs
- BoundField.cs
- DbSetClause.cs
- DecoderBestFitFallback.cs
- Geometry3D.cs
- Boolean.cs
- AuthorizationSection.cs
- XmlSubtreeReader.cs
- X509CertificateValidator.cs
- FrameworkElement.cs
- DataGridViewSelectedColumnCollection.cs
- WebPartVerbsEventArgs.cs
- FormsAuthenticationUserCollection.cs
- ClearCollection.cs
- ObjectConverter.cs
- MetadataUtil.cs
- SurrogateDataContract.cs
- ProfileParameter.cs
- EncoderNLS.cs
- InheritanceContextHelper.cs
- StringPropertyBuilder.cs
- TraceRecords.cs
- MenuItemBindingCollection.cs
- Rect3DConverter.cs
- RtfNavigator.cs
- isolationinterop.cs
- RowToParametersTransformer.cs
- wgx_sdk_version.cs
- ConnectionStringsExpressionBuilder.cs
- SoapIgnoreAttribute.cs
- StylusPointPropertyId.cs
- BindingGraph.cs
- ReadOnlyDictionary.cs
- AlphabetConverter.cs
- ByteStreamGeometryContext.cs
- CompilerGeneratedAttribute.cs
- SectionUpdates.cs
- EventRecord.cs
- GlobalItem.cs
- ImageCreator.cs
- DependencySource.cs
- HashHelper.cs
- Lazy.cs
- AuthorizationRule.cs
- StatusBarDrawItemEvent.cs
- AnnotationMap.cs
- UserControl.cs
- XmlNamespaceDeclarationsAttribute.cs
- TreePrinter.cs
- ExternalDataExchangeService.cs
- FileLogRecordHeader.cs
- MLangCodePageEncoding.cs
- WorkflowMarkupSerializationManager.cs
- HttpContext.cs
- HttpServerVarsCollection.cs
- MessageDecoder.cs
- SqlUserDefinedAggregateAttribute.cs
- PerSessionInstanceContextProvider.cs
- DomNameTable.cs
- HtmlShimManager.cs
- WorkflowFileItem.cs
- AsyncContentLoadedEventArgs.cs
- SystemPens.cs
- ParamArrayAttribute.cs
- MenuItemBindingCollection.cs
- ActivityContext.cs
- odbcmetadatacolumnnames.cs
- OrderedDictionaryStateHelper.cs
- RubberbandSelector.cs
- MailWebEventProvider.cs
- WebPartConnectVerb.cs
- _AcceptOverlappedAsyncResult.cs
- MetadataPropertyvalue.cs
- XmlSortKey.cs
- ClientSponsor.cs
- formatter.cs
- DecoderExceptionFallback.cs