Skip to content

Add IValueConverters to CommunityToolkit.MVVM #670

@AchimStuy

Description

@AchimStuy

Overview

We would like to migrate from our own MVVM library to CommunityToolkit.MVVM. In our library we have implemented several frequently used IValueConverters, which I would like to have in the CommunityToolkit. Can these be added? Where? I'd propose a new folder Converters in the CommunityToolkit.Mvvm project.

API breakdown

  • BooleanConverters:
    • InverseBooleanConverter
    • NullBooleanConverter
  • VisibilityConverters:
    • BooleanVisibilityConverter
    • NullVisiblilityConverter

(each with Reverse property)

Usage example

<Window
    xmlns:conv="clr-namespace:CommunityToolkit.Mvvm.Converters;assembly=CommunityToolkit.Mvvm"
    >
    <Window.Resources>
        <conv:NullBooleanConverter x:Name="NullBooleanConverter" />
        <conv:NullVisibilityConverter x:Name="NullVisibilityConverter" />
    </Window.Resources>
    
    <Grid>
        <ListBox ItemsSource="{Binding Items}" Visibility="{Binding Items, Converter={StaticResource NullVisibilityConverter}}" />
        <Button Content="Submit" IsEnabled="{Binding Data, Converter={StaticResource NullBooleanConverter}}" />
    </Grid>
</Window>

Breaking change?

No

Alternatives

The converters could also be added to the .NET code, but this would not make it available to our net48 applications.

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request 📬A request for new changes to improve functionalitymvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions