Fixed some broken links, added/updated examples in trigger-related docs (#989)

* Fixed some broken links and added/updated examples in trigger-related docs

* Update docs
This commit is contained in:
Mike Norman 2017-06-14 10:54:23 -05:00 коммит произвёл GitHub
Родитель 10ae30489a
Коммит 347ec70afc
6 изменённых файлов: 161 добавлений и 22 удалений

Просмотреть файл

@ -426,7 +426,7 @@ button.HeightRequest = Device.OnPlatform (20,30,30);
</ReturnValue> </ReturnValue>
<Docs> <Docs>
<summary>Gets the <see cref="T:Xamarin.Forms.TargetPlatform" /> indicating the OS Xamarin.Forms is working on.</summary> <summary>Gets the <see cref="T:Xamarin.Forms.TargetPlatform" /> indicating the OS Xamarin.Forms is working on.</summary>
<value>A <see cref="Xamarin.Forms.TargetPlatform" /> that indicates the current OS.</value> <value>A <see cref="T:Xamarin.Forms.TargetPlatform" /> that indicates the current OS.</value>
<remarks> <remarks>
</remarks> </remarks>
</Docs> </Docs>

Просмотреть файл

@ -21,25 +21,51 @@
<Docs> <Docs>
<summary>Class that represents a triggering event and a list of <see cref="T:Xamarin.Forms.TriggerAction" /> objects that will be invoked when the event is raised.</summary> <summary>Class that represents a triggering event and a list of <see cref="T:Xamarin.Forms.TriggerAction" /> objects that will be invoked when the event is raised.</summary>
<remarks> <remarks>
<para>XAML for Xamarin.Forms supports the following property for the <see cref="T:Xamarin.Forms.EventTrigger" /> class:</para> <example>
<list type="table"> <para>The example below shows how developers can use an event trigger to respond to events and update the value of a control property.</para>
<listheader> <para>With the <c>ColorTriggerAction</c> class below defined in the <c>TriggerDemo</c> namespace:</para>
<term>Property</term> <code lang="C#"><![CDATA[public class ColorTriggerAction : TriggerAction<Entry>
<description>Value</description> {
</listheader> protected override void Invoke(Entry sender)
<item> {
<term>Event</term> Color[] color ={ Color.Red,
<description> Color.Orange,
<para>The name of the event to which to respond.</para> Color.Yellow,
</description> Color.Green,
</item> Color.Blue,
<item> Color.Indigo,
<term>Object name</term> Color.Violet };
<description> sender.TextColor = color[sender.Text.Length % color.Length];
<para>The qualified name of a <see cref="T:Xamarin.Forms.TriggerAction`1" /> implementation that has been defined by the application developer. This object is instantiated and its <see cref="M:Xamarin.Forms.TriggerAction`1.Invoke" /> method is called when the triggering event is raised. Attributes on this tag set corresponding proptery values on the <see cref="T:Xamarin.Forms.TriggerAction`1" /> implementation</para> before the <see cref="M:Xamarin.Forms.TriggerAction`1.Invoke" /> method is called.</description> }
</item> }]]></code>
</list> <para>the developer can use the XAML below to create a page that cycles the colors of a <see cref="T:Xamarin.Forms.Entry" /> text area through the colors of the rainbow as the user enters text.</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="Do you see colors?"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Entry Placeholder="Type stuff here."
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="Black">
<Entry.Triggers>
<EventTrigger Event="TextChanged" >
<local:ColorTriggerAction />
</EventTrigger>
</Entry.Triggers>
</Entry>
</StackLayout>
</ContentPage>]]></code>
</example>
</remarks> </remarks>
<altmember cref="T:Xamarin.Forms.Setter" />
<altmember cref="T:Xamarin.Forms.PropertyCondition" />
<altmember cref="T:Xamarin.Forms.DataTrigger" />
<altmember cref="T:Xamarin.Forms.Trigger" />
</Docs> </Docs>
<Members> <Members>
<Member MemberName=".ctor"> <Member MemberName=".ctor">

Просмотреть файл

@ -553,7 +553,7 @@ namespace FormsGallery
</ReturnValue> </ReturnValue>
<Parameters /> <Parameters />
<Docs> <Docs>
<summary>Method that is called when the <see cref="P:Xamarin.Forms.Element.Parent" /> property of this <see cref="Xamarin.Forms.MasterDetailPage" /> is set.</summary> <summary>Method that is called when the <see cref="P:Xamarin.Forms.Element.Parent" /> property of this <see cref="T:Xamarin.Forms.MasterDetailPage" /> is set.</summary>
<remarks>To be added.</remarks> <remarks>To be added.</remarks>
</Docs> </Docs>
</Member> </Member>

Просмотреть файл

@ -26,7 +26,79 @@
</Attributes> </Attributes>
<Docs> <Docs>
<summary>Class that represents a property condition and an action that is performed when the condition is met.</summary> <summary>Class that represents a property condition and an action that is performed when the condition is met.</summary>
<remarks>To be added.</remarks> <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" />
</Docs> </Docs>
<Members> <Members>
<Member MemberName=".ctor"> <Member MemberName=".ctor">

Просмотреть файл

@ -24,7 +24,48 @@
<typeparam name="T">The type of which the <see cref="P:Xamarin.Forms.TriggerAction`1.AttachedObject" /> property must be an instance.</typeparam> <typeparam name="T">The type of which the <see cref="P:Xamarin.Forms.TriggerAction`1.AttachedObject" /> property must be an instance.</typeparam>
<summary>A generic base class for user-defined actions that are performed when a trigger condition is met.</summary> <summary>A generic base class for user-defined actions that are performed when a trigger condition is met.</summary>
<remarks> <remarks>
<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> </remarks>
<altmember cref="T:Xamarin.Forms.Setter" />
<altmember cref="T:Xamarin.Forms.PropertyCondition" />
<altmember cref="T:Xamarin.Forms.DataTrigger" />
</Docs> </Docs>
<Members> <Members>
<Member MemberName=".ctor"> <Member MemberName=".ctor">

Просмотреть файл

@ -140,7 +140,7 @@
<Docs> <Docs>
<param name="center">To be added.</param> <param name="center">To be added.</param>
<param name="radius">To be added.</param> <param name="radius">To be added.</param>
<summary>Returns a <see cref="Xamarin.Forms.Maps.MapSpan" /> that displays the area that is defined by <paramref name="center" /> and <paramref name="radius" />.</summary> <summary>Returns a <see cref="T:Xamarin.Forms.Maps.MapSpan" /> that displays the area that is defined by <paramref name="center" /> and <paramref name="radius" />.</summary>
<returns>To be added.</returns> <returns>To be added.</returns>
<remarks>To be added.</remarks> <remarks>To be added.</remarks>
</Docs> </Docs>