Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Enum to Boolean Converter #371

@WebDucer

Description

@WebDucer

Summary

It is often needed to activate / deactivate controls dependent on an Enum value.

Intended Use Case

<conv:EnumToBoolConverter x:Key="EnumConverter" />
...
<Button
  IsEnabled="{Binding WorkflowState, Converter={StaticResource EnumConverter}, ConverterParameter={x:Static enum:WorflowState.Staging}}"
  Text="Deploy" />
<conv:EnumToBoolConverter x:Key="EnumConverter" Invert="True" />
...
<Button
  IsVisible="{Binding WorkflowState, Converter={StaticResource EnumConverter}, ConverterParameter={x:Static enum:WorflowState.Finished}}"
  Text="Next" />

As configuration with multiple states

<conv:EnumsToBoolConverter x:Key="EnumConverter" Invert="True">
  <conv:EnumsToBoolConverter.Values>
    <enum:WorkflowState.Commit />
    <enum:WorkflowState.Build />
    <enum:WorkflowState.Staging />
    <enum:WorkflowState.QA />
  </conv:EnumsToBoolConverter.Values>
</conv:EnumsToBoolConverter>
...
<Button
  IsVisible="{Binding WorkflowState, Converter={StaticResource EnumConverter}}"
  Text="Finish" />

Who Will Do The Work?

  • I am willing to take this on myself

Metadata

Metadata

Assignees

No one assigned

    Labels

    a/convertersThis issue/PR is related to convertersfeature-requestA request for a new feature.in-progressActively being worked on.ready-to-implementFeature approved, specs written, and ready to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions