Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CommunityToolkit.Maui.Sample.Pages.Converters.CompareConverterPage"
xmlns:vm="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Converters"
xmlns:converters="clr-namespace:CommunityToolkit.Maui.Sample.Converters"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
x:TypeArguments="vm:CompareConverterViewModel"
x:DataType="vm:CompareConverterViewModel">
<pages:BasePage
x:Class="CommunityToolkit.Maui.Sample.Pages.Converters.CompareConverterPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:converters="clr-namespace:CommunityToolkit.Maui.Sample.Converters"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
xmlns:vm="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Converters"
x:DataType="vm:CompareConverterViewModel"
x:TypeArguments="vm:CompareConverterViewModel">

<pages:BasePage.Resources>
<ResourceDictionary>
<x:Double x:Key="ComparingValue">0.5</x:Double>
<x:Double x:Key="ComparingValue">5.0</x:Double>
<Color x:Key="LightGreen">LightGreen</Color>
<Color x:Key="PaleVioletRed">PaleVioletRed</Color>

<converters:CompareDoubleToColorConverter
x:Key="isLargerThanOneConverter"
ComparingValue="1"
ComparisonOperator="Greater"
TrueObject="LightGreen"
FalseObject="PaleVioletRed" />
FalseObject="PaleVioletRed"
TrueObject="LightGreen" />
</ResourceDictionary>
</pages:BasePage.Resources>

<VerticalStackLayout Spacing="20">

<Label
Text="The CompareConverter is a Converter that converts an object of a type implementing IComparable, and returns the comparison result as a bool if no objects were specified through the TrueObject and/or FalseObject properties. If values are assigned to the TrueObject and/or FalseObject properties, the CompareConverter returns the respective object assigned."
TextColor="{StaticResource NormalLabelTextColor}"/>
<Label Text="The CompareConverter is a Converter that converts an object of a type implementing IComparable, and returns the comparison result as a bool if no objects were specified through the TrueObject and/or FalseObject properties. If values are assigned to the TrueObject and/or FalseObject properties, the CompareConverter returns the respective object assigned." TextColor="{StaticResource NormalLabelTextColor}" />

<Slider
HorizontalOptions="FillAndExpand"
Maximum="10"
Minimum="0"
Value="{Binding SliderValue, Mode=TwoWay}"
HorizontalOptions="FillAndExpand"/>
Value="{Binding SliderValue, Mode=TwoWay}" />

<Label
Text="The background of this label will be green if the value of the slider is greater than 1, and red otherwise."
<Label
Padding="4,0"
BackgroundColor="{Binding SliderValue, Mode=OneWay, Converter={StaticResource isLargerThanOneConverter}}"
TextColor="Black"
Padding="4, 0"/>
Text="The background of this label will be green if the value of the slider is greater than 1, and red otherwise."
TextColor="Black" />

<Label
Text="The following label will show whether the value of the slider is greater than or equal to 50%:"
TextColor="{StaticResource NormalLabelTextColor}"/>
<Label Text="The following label will show whether the value of the slider is greater than or equal to 50%:" TextColor="{StaticResource NormalLabelTextColor}" />

<Label
Text="{Binding SliderValue, Mode=OneWay, Converter={mct:CompareConverter ComparingValue={StaticResource ComparingValue}, ComparisonOperator=GreaterOrEqual}}" />
<Label Text="{Binding SliderValue, Mode=OneWay, Converter={mct:CompareConverter ComparingValue={StaticResource ComparingValue}, ComparisonOperator=GreaterOrEqual}}" />

</VerticalStackLayout>
</pages:BasePage>