summaryrefslogtreecommitdiff
path: root/docs/Xamarin.Forms.Core/Xamarin.Forms/Trigger.xml
blob: d526a619e172918d41c20285c0b367c62c2311c7 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<Type Name="Trigger" FullName="Xamarin.Forms.Trigger">
  <TypeSignature Language="C#" Value="public sealed class Trigger : Xamarin.Forms.TriggerBase, Xamarin.Forms.Xaml.IValueProvider" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit Trigger extends Xamarin.Forms.TriggerBase implements class Xamarin.Forms.Xaml.IValueProvider" />
  <AssemblyInfo>
    <AssemblyName>Xamarin.Forms.Core</AssemblyName>
    <AssemblyVersion>1.3.0.0</AssemblyVersion>
    <AssemblyVersion>1.4.0.0</AssemblyVersion>
    <AssemblyVersion>1.5.0.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>Xamarin.Forms.TriggerBase</BaseTypeName>
  </Base>
  <Interfaces>
    <Interface>
      <InterfaceName>Xamarin.Forms.Xaml.IValueProvider</InterfaceName>
    </Interface>
  </Interfaces>
  <Attributes>
    <Attribute>
      <AttributeName>Xamarin.Forms.ContentProperty("Setters")</AttributeName>
    </Attribute>
    <Attribute>
      <AttributeName>Xamarin.Forms.Xaml.AcceptEmptyServiceProvider</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <summary>Class that represents a property condition and an action that is performed when the condition is met.</summary>
    <remarks>
      <para>The <see cref="T:Xamarin.Forms.Trigger" /> class is suitable for checking the values of any property on the control to which it has been added. That is, its default binding context is the control to which it has been added. To bind on controls other than the parent, developers should use the <see cref="T:Xamarin.Forms.DataTrigger" /> class, instead.</para>
      <example>
        <para>The XML example below prompts the user to type in the secret, which is, "The text color is red". When the user has typed the secret, the Entry text changes color to red. The code is turned back to the default color if the user then edits the text to differ from the secret. This example shows how to bind to the enclosing control with a trigger.</para>
        <code lang="XML"><![CDATA[

<?xml version="1.0" encoding="utf-8"?>
<ContentPage    xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:TriggerDemo"
                x:Class="TriggerDemo.TriggerDemoPage">
    <StackLayout VerticalOptions="Center">
        <Label Text="Tell me the secret"
               VerticalOptions="Center"
               HorizontalOptions="Center" />
        <Entry Placeholder="Type the secret here."
               VerticalOptions="Center"
               HorizontalOptions="Center">
            <Entry.Triggers>
                <Trigger TargetType="Entry"
                    Property="Text"
                    Value="The text color is red">
                    <Setter Property="TextColor" Value="Red" />
                </Trigger>
            </Entry.Triggers>
        </Entry>
    </StackLayout>
</ContentPage>

]]></code>
      </example>
      <example>
        <para>The example below shows how developers can use a trigger to respond to events and update the value of a control property by using <see cref="T:Xamarin.Forms.TriggerAction{T}" /> classes. The example prompts the user to answer a question about the color of the text, and then calls <c>ColorTriggerAction</c> to turn the text red when the user types "The text color is red". Developers should note that, while this example does not change the text back to the default color when the user continues to edit the string, the developer could additionally implement and specify an exit action to obtain that result.</para>
        <para>With the ColorTriggerAction class below defined in the <c>TriggerDemo</c> namespace:</para>
        <code lang="C#"><![CDATA[public class ColorTriggerAction : TriggerAction<Entry>
{
    protected override void Invoke(Entry sender)
    {
        sender.TextColor = Color.Red;
    }
}]]></code>
        <para>the developer can use the XAML below to create the page that responds to the secret string by changing the color of the <see cref="T:Xamarin.Forms.Entry" /> text area to red.</para>
        <code lang="XAML"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<ContentPage    xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:TriggerDemo"
                x:Class="TriggerDemo.TriggerDemoPage">
    <StackLayout VerticalOptions="Center">
        <Label Text="What color is &quot;The text&quot;?"
               VerticalOptions="Center"
               HorizontalOptions="Center" />
        <Entry Placeholder="Type answer here."
               VerticalOptions="Center"
               HorizontalOptions="Center"
               BackgroundColor="White">
            <Entry.Triggers>
                <Trigger TargetType="Entry"
                         Property="Text"
                         Value="The text is red" >
                    <Trigger.EnterActions>
                        <local:ColorTriggerAction />
                    </Trigger.EnterActions>
                </Trigger>
            </Entry.Triggers>
        </Entry>
    </StackLayout>
</ContentPage>
]]></code>
      </example>
    </remarks>
    <altmember cref="T:Xamarin.Forms.Setter" />
    <altmember cref="T:Xamarin.Forms.PropertyCondition" />
    <altmember cref="T:Xamarin.Forms.DataTrigger" />
    <altmember cref="T:Xamarin.Forms.TriggerAction{T}" />
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public Trigger (Type targetType);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Type targetType) cil managed" />
      <MemberType>Constructor</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.3.0.0</AssemblyVersion>
        <AssemblyVersion>1.4.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <Parameters>
        <Parameter Name="targetType" Type="System.Type">
          <Attributes>
            <Attribute>
              <AttributeName>Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.TypeTypeConverter))</AttributeName>
            </Attribute>
          </Attributes>
        </Parameter>
      </Parameters>
      <Docs>
        <param name="targetType">The view type to which the trigger will be added.</param>
        <summary>Initializes a new <see cref="T:Xamarin.Forms.Trigger" /> instance.</summary>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Property">
      <MemberSignature Language="C#" Value="public Xamarin.Forms.BindableProperty Property { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance class Xamarin.Forms.BindableProperty Property" />
      <MemberType>Property</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.3.0.0</AssemblyVersion>
        <AssemblyVersion>1.4.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>Xamarin.Forms.BindableProperty</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Gets or sets the property whose value will be compared to <see cref="P:Xamarin.Forms.Trigger.Value" /> to determine when to invoke the setters.</summary>
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Setters">
      <MemberSignature Language="C#" Value="public System.Collections.Generic.IList&lt;Xamarin.Forms.Setter&gt; Setters { get; }" />
      <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IList`1&lt;class Xamarin.Forms.Setter&gt; Setters" />
      <MemberType>Property</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.3.0.0</AssemblyVersion>
        <AssemblyVersion>1.4.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Collections.Generic.IList&lt;Xamarin.Forms.Setter&gt;</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Gets the list of <see cref="T:Xamarin.Forms.Setter" /> objects that will be applied when the property that is named by <see cref="P:Xamarin.Forms.Trigger.Property" /> becomes equal to <see cref="P:Xamarin.Forms.Trigger.Value" />.</summary>
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Value">
      <MemberSignature Language="C#" Value="public object Value { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance object Value" />
      <MemberType>Property</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.3.0.0</AssemblyVersion>
        <AssemblyVersion>1.4.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Gets or sets the value of the property, named by the <see cref="P:Xamarin.Forms.Trigger.Property" /> property, that will cause the setters to be applied.</summary>
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Xamarin.Forms.Xaml.IValueProvider.ProvideValue">
      <MemberSignature Language="C#" Value="object IValueProvider.ProvideValue (IServiceProvider serviceProvider);" />
      <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance object Xamarin.Forms.Xaml.IValueProvider.ProvideValue(class System.IServiceProvider serviceProvider) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.3.0.0</AssemblyVersion>
        <AssemblyVersion>1.4.0.0</AssemblyVersion>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="serviceProvider" Type="System.IServiceProvider" />
      </Parameters>
      <Docs>
        <param name="serviceProvider">For internal use by the Xamarin.Forms platform.</param>
        <summary>For internal use by the Xamarin.Forms platform.</summary>
        <returns>To be added.</returns>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>