-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
AmbientAttribute.xml
124 lines (110 loc) · 10.6 KB
/
AmbientAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<Type Name="AmbientAttribute" FullName="System.Windows.Markup.AmbientAttribute">
<TypeSignature Language="C#" Value="public sealed class AmbientAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit AmbientAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.Windows.Markup.AmbientAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class AmbientAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type AmbientAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class AmbientAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.Xaml</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="WindowsBase" FromVersion="4.0.0.0" To="System.Xaml" ToVersion="4.0.0.0" FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;windowsdesktop-3.0;windowsdesktop-3.1" />
<TypeForwarding From="WindowsBase" FromVersion="5.0.0.0" To="System.Xaml" ToVersion="5.0.0.0" FrameworkAlternate="windowsdesktop-5.0" />
<TypeForwarding From="WindowsBase" FromVersion="6.0.0.0" To="System.Xaml" ToVersion="6.0.0.0" FrameworkAlternate="windowsdesktop-6.0" />
<TypeForwarding From="WindowsBase" FromVersion="7.0.0.0" To="System.Xaml" ToVersion="7.0.0.0" FrameworkAlternate="windowsdesktop-7.0" />
<TypeForwarding From="WindowsBase" FromVersion="8.0.0.0" To="System.Xaml" ToVersion="8.0.0.0" FrameworkAlternate="windowsdesktop-8.0" />
<TypeForwarding From="WindowsBase" FromVersion="9.0.0.0" To="System.Xaml" ToVersion="9.0.0.0" FrameworkAlternate="windowsdesktop-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5">
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Property, Inherited=true)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Property, Inherited=true)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0">
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property, Inherited=true)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property, Inherited=true)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies that a property or type should be treated as ambient. The ambient concept relates to how XAML processors determine type owners of members.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
An ambient property is a property where the value is expected to be available in the parser context when creating an object graph, but where typical type-member lookup is suspended for purposes of the immediate XAML node set being created. There are two main scenarios for the ambient concept:
- Some other property of the same object influences and qualifies how that object-property lookup should work.
- The property represents a larger deferral mechanism and the ambient capabilities for looking up a member value extend to all objects contained within the current object.
This attribute can be applied to specific properties that have expected containers that enable an ambient property lookup behavior, or can be applied to a class to enable the ambient property behavior in all cases of that value type for a property.
<xref:System.Windows.Markup.AmbientAttribute> can also be applied to a CLR method, to support attributing a XAML attachable property as ambient. This is potentially necessary because in a CLR implementation a XAML attached property is implemented/represented to reflection as an accessor pattern with `get` and `set` methods. No actual CLR property to attribute exists, so restricting usage for <xref:System.AttributeTargets> to `Property` would not have enabled specifying an attachable member as ambient. For an attachable member that you want to report as ambient, attribute the `get` accessor. You should not attempt to attribute methods that are not specifically support methods of attachable members.
In previous versions of the .NET Framework, this class existed in the WPF-specific assembly WindowsBase. In .NET Framework 4, <xref:System.Windows.Markup.AmbientAttribute> is in the System.Xaml assembly. For more information, see [Types Migrated from WPF to System.Xaml](/dotnet/framework/xaml-services/types-migrated-from-wpf-to-system-xaml).
Ambient types (types where <xref:System.Windows.Markup.AmbientAttribute> is applied at type level) can be used for certain XAML processing situations where the type of a property needs to be resolved out of order.
## Object Writer Scenarios
If you are defining a XAML object writer, and you encounter a property, method or type where <xref:System.Windows.Markup.AmbientAttribute> is applied, you typically must access a service to determine the intended ambient property lookup behavior that is needed for writing out objects. For more information, see <xref:System.Xaml.IAmbientProvider>.
## Value Converters
Type converters or markup extensions might need to know the ambient information in order to process properties that represent indirect type mappings, such as properties that specify members or types by string names with or without qualification. In this scenario, <xref:System.Windows.Markup.AmbientAttribute> is not intended to be used directly for value converter code logic. Rather, the value converter should rely on the XAML writer processing behavior, which will pass <xref:System.Xaml.IAmbientProvider> in its service contexts to your value converter methods when called.
## WPF Scenarios for AmbientAttribute
- A property of a <xref:System.Windows.Style> (<xref:System.Windows.Style.TargetType%2A>) can qualify the necessary property name lookups that are needed to find the backing references for property names in <xref:System.Windows.Setter.Property%2A?displayProperty=nameWithType> values.
- All content within a `Resources` property (items of a <xref:System.Windows.ResourceDictionary>) as well as template content, should be able to access other peers as values. Declaring the entire `Resources` property as ambient invokes logic that enables this in the WPF XAML parser.
See <xref:System.Windows.ResourceDictionary> for an example of a scenario for setting <xref:System.Windows.Markup.AmbientAttribute> at type level.
]]></format>
</remarks>
<altmember cref="P:System.Xaml.XamlMember.IsAmbient" />
<altmember cref="T:System.Xaml.XamlMember" />
<altmember cref="T:System.Xaml.IAmbientProvider" />
<related type="Article" href="/dotnet/desktop-wpf/xaml-services/clr-attributes-with-custom-types-and-libraries">XAML-related CLR attributes for custom types and libraries</related>
<related type="Article" href="/dotnet/desktop-wpf/xaml-services/define-custom-types">Define custom types for use with .NET XAML Services</related>
<related type="Article" href="/dotnet/desktop-wpf/xaml-services/">XAML Services</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public AmbientAttribute ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Markup.AmbientAttribute.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 AmbientAttribute();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Xaml</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Markup.AmbientAttribute" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>