Type of issue
Code doesn't work
Description
The given examples for creating a two way converter and one way converter have the wrong return types.
The code as written for the two way coverter is:
public class BoolToColorConverter : BaseConverter<bool, Color>
{
public override Color DefaultConvertReturnValue { get; set; } = Colors.Orange;
public override bool DefaultConvertBackReturnValue { get; set; } = false;
public override string ConvertFrom(bool value, CultureInfo? culture)
{
return value ? Colors.Green : Colors.Red;
}
public override int ConvertBackTo(Color value, CultureInfo? culture)
{
return value == Colors.Green;
}
}
it should be
public class BoolToColorConverter : BaseConverter<bool, Color>
{
public override Color DefaultConvertReturnValue { get; set; } = Colors.Orange;
public override bool DefaultConvertBackReturnValue { get; set; } = false;
public override Color ConvertFrom(bool value, CultureInfo? culture)
{
return value ? Colors.Green : Colors.Red;
}
public override bool ConvertBackTo(Color value, CultureInfo? culture)
{
return value == Colors.Green;
}
}
The one way converter has the same issue with the overide for ConvertFrom()
Page URL
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/converters/
Content source URL
https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/maui/converters/index.md
Document Version Independent Id
c058518f-3a9b-7df9-6c1a-ec4bf98eefc6
Platform Id
9ba182ca-81a5-7dfc-3f78-99720fceb9da
Article author
@bijington
Metadata
- ID: c058518f-3a9b-7df9-6c1a-ec4bf98eefc6
- PlatformId: 9ba182ca-81a5-7dfc-3f78-99720fceb9da
- Service: dotnet-communitytoolkit
- Sub-service: dotnet-maui-community-toolkit
Type of issue
Code doesn't work
Description
The given examples for creating a two way converter and one way converter have the wrong return types.
The code as written for the two way coverter is:
it should be
The one way converter has the same issue with the overide for ConvertFrom()
Page URL
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/converters/
Content source URL
https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/maui/converters/index.md
Document Version Independent Id
c058518f-3a9b-7df9-6c1a-ec4bf98eefc6
Platform Id
9ba182ca-81a5-7dfc-3f78-99720fceb9da
Article author
@bijington
Metadata