-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Information label and bound value in CompareConverter sample don't ma…
…tch (#1981) Fixed #1980 Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
- Loading branch information
1 parent
41ad501
commit cc1fb68
Showing
1 changed file
with
24 additions
and
28 deletions.
There are no files selected for viewing
52 changes: 24 additions & 28 deletions
52
samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |