Two and One Way Converter Examples Don't Work
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 91/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- csharp
- Domain
- documentation
Research direction
Open docs/maui/converters/index.md and find the two-way and one-way converter examples referenced by the issue. Correct the documented ConvertFrom and ConvertBackTo return types to match BaseConverter<bool, Color>, then review the rendered examples to confirm both compile conceptually and show the intended signatures.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- No language data
- Stars
- 168
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MicrosoftDocs/CommunityToolkit
-
Just a typo? Opencommunity-toolkit/prod dotnet Pri2
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
dotnet-communitytoolkit/prod maui Pri1
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
dotnet dotnet-communitytoolkit/prod Pri1
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
MicrosoftDocs/CommunityToolkit#659 · 1 comment ·
-
A Opendotnet-communitytoolkit/svc Pri2 windows-community-toolkit/subsvc
Difficulty 1/5 Under an hour Newbie friendliness 25/100
MicrosoftDocs/CommunityToolkit#644 · 3 comments ·
All issues in MicrosoftDocs/CommunityToolkit
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·