summaryrefslogtreecommitdiff
path: root/docs/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorMike Norman <mknorman@gmail.com>2017-06-13 15:51:44 (GMT)
committerGitHub <noreply@github.com>2017-06-13 15:51:44 (GMT)
commitc94331368f65353fe225ee296b6c38b697c17d73 (patch)
treec556f44719d4c21e9722783828ac8eadef68d0b8 /docs/Xamarin.Forms.Core
parent67f9744c48e87b552dcf05d0dc55dcc091f4860b (diff)
downloadxamarin-forms-c94331368f65353fe225ee296b6c38b697c17d73.zip
xamarin-forms-c94331368f65353fe225ee296b6c38b697c17d73.tar.gz
xamarin-forms-c94331368f65353fe225ee296b6c38b697c17d73.tar.bz2
Updated some more code examples related to triggers and conditions. (#986)
* Updated some more code examples related to triggers and conditions. * Touchup docs
Diffstat (limited to 'docs/Xamarin.Forms.Core')
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/Binding.xml2
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/BindingCondition.xml13
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/BindingTypeConverter.xml26
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/DataTrigger.xml62
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/MultiTrigger.xml58
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/PropertyCondition.xml42
6 files changed, 124 insertions, 79 deletions
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/Binding.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/Binding.xml
index b16a446..713d416 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/Binding.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/Binding.xml
@@ -271,7 +271,7 @@ public class PersonViewModel
var label = new Label ();
PersonViewModel person;
-label.BindingContext = person = new PersonViewModel { Name = "John Doe", Company= "Xamarin" };
+label.BindingContext = person = new PersonViewModel { Name = "John Doe", Company = "Microsoft" };
label.SetBinding (Label.TextProperty, Binding.Create<PersonViewModel> (vm => vm.Name));
Debug.WriteLine (label.Text); //prints "John Doe".
]]></code>
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingCondition.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingCondition.xml
index ddebc6d..06e1479 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingCondition.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingCondition.xml
@@ -23,7 +23,18 @@
</Attributes>
<Docs>
<summary>Class that represents a value comparison with the target of an arbitrary binding.</summary>
- <remarks>To be added.</remarks>
+ <remarks>
+ <para>The <see cref="T:Xamarin.Forms.BindingCondition" /> class can compare a value a binding on any class within the current scope. Developers who want to compare to a value to a bound property on the control that contains the conditions surrounding <see cref="T:Xamarin.Forms.MultiTrigger" /> may want to use a <see cref="T:Xamarin.Forms.PropertyCondition" /> in addition to any binding conditions in the trigger list. </para>
+ <example>
+ <para>The XML example below creates a binding condition within a surrounding <see cref="T:Xamarin.Forms.MultiTrigger" /> (omitted) that succeeds when the referenced <c>name</c> has a <c>Text.Length</c> property length that is equal to <c>0</c>. (<c>name</c> must refer to an element, such as a <see cref="T:Xamarin.Forms.TextCell" />, that has a <c>Text</c> property that, in turn, has a <c>Length</c> property.)</para>
+ <code lang="XML"><![CDATA[
+ <BindingCondition Binding="{Binding Source={x:Reference name},
+ Path=Text.Length}"
+ Value="0" />]]></code>
+ </example>
+ </remarks>
+ <altmember cref="T:Xamarin.Forms.MultiTrigger" />
+ <altmember cref="T:Xamarin.Forms.PropertyCondition" />
</Docs>
<Members>
<Member MemberName=".ctor">
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingTypeConverter.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingTypeConverter.xml
index f10b2a2..59e907d 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingTypeConverter.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/BindingTypeConverter.xml
@@ -16,7 +16,7 @@
</Base>
<Interfaces />
<Docs>
- <summary>Type converter that converts from source types to <see cref="T:Xamarin.Forms.Binding" /></summary>
+ <summary>Type converter that converts from strings to <see cref="T:Xamarin.Forms.Binding" /> objects.</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
@@ -58,10 +58,12 @@
<Parameter Name="sourceType" Type="System.Type" />
</Parameters>
<Docs>
- <param name="sourceType">To be added.</param>
+ <param name="sourceType">The source type of the object to check.</param>
<summary>Returns a Boolean value that indicates whether this <see cref="T:Xamarin.Forms.BindingTypeConverter" /> can convert <paramref name="sourceType" /> to <see cref="T:Xamarin.Forms.Binding" />.</summary>
- <returns>To be added.</returns>
- <remarks>To be added.</remarks>
+ <returns>
+ <see langword="true" /> if <paramref name="sourceType" /> represents a string. Otherwise, <see langword="false" />.</returns>
+ <remarks>
+ <see cref="T:Xamarin.Forms.TypeConverter" /> objects can only convert strings.</remarks>
</Docs>
</Member>
<Member MemberName="ConvertFrom">
@@ -84,11 +86,12 @@
<Parameter Name="value" Type="System.Object" />
</Parameters>
<Docs>
- <param name="culture">To be added.</param>
- <param name="value">To be added.</param>
+ <param name="culture">The culture of the object to convert.</param>
+ <param name="value">The object to convert.</param>
<summary>Converts <paramref name="value" /> to <see cref="T:Xamarin.Forms.Binding" /> by using <paramref name="culture" />.</summary>
- <returns>To be added.</returns>
- <remarks>To be added.</remarks>
+ <returns>Returns a new <see cref="T:Xamarin.Forms.Binding" /> object for the provided string.</returns>
+ <remarks>
+ <paramref name="value" /> must be a string.</remarks>
</Docs>
</Member>
<Member MemberName="ConvertFromInvariantString">
@@ -105,10 +108,11 @@
<Parameter Name="value" Type="System.String" />
</Parameters>
<Docs>
- <param name="value">To be added.</param>
+ <param name="value">The path of the resulting binding.</param>
<summary>Converts a property path to a binding.</summary>
- <returns>To be added.</returns>
- <remarks>To be added.</remarks>
+ <returns>A binding, with the default binding mode, that binds to the path that was specified with <paramref name="value" />.</returns>
+ <remarks>
+ <paramref name="value" /> must be a string.</remarks>
</Docs>
</Member>
</Members>
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/DataTrigger.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/DataTrigger.xml
index e5758fc..44e2b81 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/DataTrigger.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/DataTrigger.xml
@@ -25,33 +25,41 @@
</Attribute>
</Attributes>
<Docs>
- <summary>Class that represents a binding condition and a list of <see cref="T:Xamarin.Forms.Setter" /> objects that will be applied when the condition is met.</summary>
+ <summary>Class that represents a condition on an arbitrary binding, along with a list of <see cref="T:Xamarin.Forms.Setter" /> objects that will be applied when the condition is met.</summary>
<remarks>
- <para>XAML for Xamarin.Forms supports the following properties for the <see cref="T:Xamarin.Forms.DataTrigger" /> class:</para>
- <list type="table">
- <listheader>
- <term>Property</term>
- <description>Value</description>
- </listheader>
- <item>
- <term>Property</term>
- <description>
- <para>The name of the property whose value to compare against <c>Value</c>.</para>
- </description>
- </item>
- <item>
- <term>Value</term>
- <description>
- <para>The value of the property that will trigger the setters in <c>Setters</c>.</para>
- </description>
- </item>
- <item>
- <term>Setters</term>
- <description>
- <para>A list of setters that are called when the property condition is met. Each <c>Setter</c> tag or tag pair in the list has a <c>Property</c> and <c>Value</c> that represents the assignments to perform when the condition is met.</para>
- </description>
- </item>
- </list>
+ <para>The <see cref="T:Xamarin.Forms.DataTrigger" /> class is suitable for checking values on other controls, as well as 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.</para>
+ <example>
+ <para>The XML example below prompts the user to type in the secret, which is, "The text color is green". When the user has typed "The", the Entry text changes color to red. When the user completes the secret, the Label text turns green. The code is turned back to the default color if the user then edits the secret. This example shows how to bind to the enclosing control (Entry from Entry), and to an arbitary control (Entry from Label)</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="Can you tell me the secret?" VerticalOptions="Center" HorizontalOptions="Center">
+ <Label.Triggers>
+ <DataTrigger TargetType="Label"
+ Binding="{Binding Source={x:Reference checkEntry},
+ Path=Text}"
+ Value="The text color is green">
+ <Setter Property="TextColor" Value="Color.Green" />
+ </DataTrigger>
+ </Label.Triggers>
+ </Label>
+ <Entry Placeholder="Type the secret here." x:Name="checkEntry" VerticalOptions="Center" HorizontalOptions="Center">
+ <Entry.Triggers>
+ <DataTrigger TargetType="Entry"
+ Binding="{Binding Text}"
+ Value="The">
+ <Setter Property="TextColor" Value="Red" />
+ </DataTrigger>
+ </Entry.Triggers>
+ </Entry>
+ </StackLayout>
+ </ContentPage>
+]]></code>
+ </example>
</remarks>
</Docs>
<Members>
@@ -75,7 +83,7 @@
</Parameter>
</Parameters>
<Docs>
- <param name="targetType">To be added.</param>
+ <param name="targetType">The type of the object on which the data trigger will be added.</param>
<summary>Initializes a new <see cref="T:Xamarin.Forms.DataTrigger" /> instance.</summary>
<remarks>To be added.</remarks>
</Docs>
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/MultiTrigger.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/MultiTrigger.xml
index 30273dc..e4e96ab 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/MultiTrigger.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/MultiTrigger.xml
@@ -20,26 +20,46 @@
<Docs>
<summary>Class that represents a list of property and binding conditions, and a list of setters that are applied when all of the conditions in the list are met.</summary>
<remarks>
- <para>XAML for Xamarin.Forms supports the following properties for the <see cref="T:Xamarin.Forms.MultiTrigger" /> class:</para>
- <list type="table">
- <listheader>
- <term>Property</term>
- <description>Value</description>
- </listheader>
- <item>
- <term>Conditions</term>
- <description>
- <para>A list of <c>PropertyCondition</c> and/or <c>BindingCondition</c> markup instances that specify the conditions that all must be met before all of the setters that are listed in <c>Setters</c> are applied.</para>
- </description>
- </item>
- <item>
- <term>Setters</term>
- <description>
- <para>A list of setters that are applied when all of the property conditions are met. Each <c>Setter</c> tag or tag pair in the list has a <c>Property</c> and <c>Value</c> that represents the assignments to perform when the condition is met.</para>
- </description>
- </item>
- </list>
+ <para>Developers can use a <see cref="T:Xamarin.Forms.MultiTrigger" /> to compare against property values on the control that contains it by using <see cref="T:Xamarin.Forms.PropertyTrigger" /> objects, or on any bound property (including those on the enclosing control) by using <see cref="T:Xamarin.Forms.BindingCondition" /> objects. These can be mixed in the same <see cref="P:Xamarin.Forms.MultiTrigger.Conditions" /> list.</para>
+ <example>
+ <para>The XML example below, when added to a Xamarin.Forms app with the correct project namespace, creates a UI that suggests that the user type in a secret and toggle a switch to check if the secret is correct. If the user enters "The text color is green", and toggles the <see cref="T:Xamarin.Forms.Switch" /> to its <c>On</c> position, then the text that the user typed into the <see cref="T:Xamarin.Forms.Entry" /> turns green. If either the text is altered to something other than the secret or the Switch is toggled to its <c>Off</c> position, the text returns to the default color</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:PropertyConditionDemo"
+ x:Class="PropertyConditionDemo.PropertyConditionDemoPage">
+ <StackLayout VerticalOptions="Center">
+ <Label Text="Do you know the secret?"
+ VerticalOptions="Center"
+ HorizontalOptions="Center" />
+ <Entry Placeholder="Type the secret!"
+ VerticalOptions="Center"
+ HorizontalOptions="Center">
+ <Entry.Triggers>
+ <MultiTrigger TargetType="Entry" >
+ <MultiTrigger.Conditions>
+ <PropertyCondition Property="Text" Value="The text color is green" />
+ <BindingCondition Binding="{Binding Source={x:Reference checkSecret},
+ Path=IsToggled}"
+ Value="true" />
+ </MultiTrigger.Conditions>
+ <Setter Property="TextColor"
+ Value="Color.Green" />
+ </MultiTrigger>
+ </Entry.Triggers>
+ </Entry>
+ <Label Text="Check the secret?"
+ VerticalOptions="Center"
+ HorizontalOptions="Center" />
+ <Switch x:Name="checkSecret"
+ VerticalOptions="Center"
+ HorizontalOptions="Center" />
+ </StackLayout>
+</ContentPage>]]></code>
+ </example>
</remarks>
+ <altmember cref="T:Xamarin.Forms.PropertyCondition" />
+ <altmember cref="T:Xamarin.Forms.BindingCondition" />
</Docs>
<Members>
<Member MemberName=".ctor">
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/PropertyCondition.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/PropertyCondition.xml
index 13c1358..c8e482a 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/PropertyCondition.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/PropertyCondition.xml
@@ -22,28 +22,30 @@
</Attribute>
</Attributes>
<Docs>
- <summary>Class that represents a value comparison with a property.</summary>
+ <summary>Class that represents a value comparison against a property on the control that contains the enclosing <see cref="T:Xamarin.Forms.MultiTrigger" />.</summary>
<remarks>
- <para>XAML for Xamarin.Forms supports the following properties for the <see cref="T:Xamarin.Forms.PropertyCondition" /> class:</para>
- <list type="table">
- <listheader>
- <term>Property</term>
- <description>Value</description>
- </listheader>
- <item>
- <term>Property</term>
- <description>
- <para>The name of the property to check.</para>
- </description>
- </item>
- <item>
- <term>Value</term>
- <description>
- <para>The value for which the condition is met.</para>
- </description>
- </item>
- </list>
+ <para>The <see cref="T:Xamarin.Forms.PropertyCondition" /> class is suitable for checking property values on the control that contains the <see cref="T:Xamarin.Forms.MultiTrigger" /> that contains it. To check values on other controls, developers can use the <see cref="T:Xamarin.Forms.BindingCondition" /> class, in addition to any property conditions in the trigger list.</para>
+ <example>
+ <para>The XML example below creates a property condition within a surrounding <see cref="T:Xamarin.Forms.MultiTrigger" /> within a <see cref="T:Xamarin.Forms.TextCell" /> that turns the text green when the secret is typed. The code is turned back to the default color if the user then edits the secret. (Typically, a <see cref="T:Xamarin.Forms.MultiTrigger" /> would have more than one condition; this example is simplified for clarity.)</para>
+ <code lang="XML"><![CDATA[
+<Entry Placeholder="Type the secret!"
+ VerticalOptions="Center"
+ HorizontalOptions="Center">
+ <Entry.Triggers>
+ <MultiTrigger TargetType="Entry" >
+ <MultiTrigger.Conditions>
+ <PropertyCondition Property="Text"
+ Value="The text color is green" />
+ </MultiTrigger.Conditions>
+ <Setter Property="TextColor"
+ Value="Color.Green" />
+ </MultiTrigger>
+ </Entry.Triggers>
+</Entry>]]></code>
+ </example>
</remarks>
+ <altmember cref="T:Xamarin.Forms.MultiTrigger" />
+ <altmember cref="T:Xamarin.Forms.BindingCondition" />
</Docs>
<Members>
<Member MemberName=".ctor">