Mythosia.Wpf 8.0.0

dotnet add package Mythosia.Wpf --version 8.0.0
                    
NuGet\Install-Package Mythosia.Wpf -Version 8.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mythosia.Wpf" Version="8.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mythosia.Wpf" Version="8.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Mythosia.Wpf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mythosia.Wpf --version 8.0.0
                    
#r "nuget: Mythosia.Wpf, 8.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mythosia.Wpf@8.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mythosia.Wpf&version=8.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Mythosia.Wpf&version=8.0.0
                    
Install as a Cake Tool

Mythosia.Wpf

This project provides a collection of useful WPF value converters that simplify data binding in XAML. These converters handle common scenarios in WPF applications and follow consistent naming and usage patterns.

Features

  • Comprehensive Converter Collection: A complete set of value converters for common WPF binding scenarios
  • Consistent API: All converters follow the same design patterns and conventions
  • Bidirectional Support: Most converters support both Convert and ConvertBack operations where applicable
  • Parameter Support: Many converters support additional customization through ConverterParameter
  • Inversion Support: Several converters support inverse behavior through parameters

Available Converters

Boolean Converters

  • BooleanToVisibilityConverter: Converts boolean values to Visibility
  • InverseBooleanConverter: Inverts boolean values (True �� False)
  • InverseBooleanToVisibilityConverter: Converts boolean to Visibility with inversion
  • BooleanToStringConverter: Converts boolean values to custom strings

String Converters

  • StringToVisibilityConverter: Converts string values to Visibility based on null/empty state

Object Converters

  • NullToVisibilityConverter: Converts null values to Visibility

Enum Converters

  • EnumToVisibilityConverter: Converts enum values to Visibility based on parameter matching
  • EnumToBooleanConverter: Converts enum values to boolean for RadioButton binding

Installation

Add a reference to the Mythosia.Wpf project or include the converter classes in your WPF application.

Usage

1. Add Namespace Reference

Add the namespace reference to your XAML file:

xmlns:converters="clr-namespace:Mythosia.Wpf.Converters"

2. Define Converters as Resources

Define the converters in your application or window resources:

<Window.Resources>
    <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
    <converters:StringToVisibilityConverter x:Key="StringToVisibility" />
    <converters:NullToVisibilityConverter x:Key="NullToVisibility" />
    <converters:BooleanToStringConverter x:Key="BooleanToString" />
    <converters:EnumToVisibilityConverter x:Key="EnumToVisibility" />
    <converters:EnumToBooleanConverter x:Key="EnumToBoolean" />
    <converters:InverseBooleanConverter x:Key="InverseBoolean" />
    <converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibility" />
</Window.Resources>

3. Use Converters in Bindings

BooleanToVisibilityConverter

<TextBlock Text="Visible when true" 
           Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibility}}" />


<TextBlock Text="Hidden when true" 
           Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibility}, ConverterParameter=Inverse}" />
StringToVisibilityConverter

<TextBlock Text="Has content" 
           Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}" />


<TextBlock Text="No content" 
           Visibility="{Binding Message, Converter={StaticResource StringToVisibility}, ConverterParameter=Inverse}" />
NullToVisibilityConverter

<Button Content="Edit" 
        Visibility="{Binding SelectedItem, Converter={StaticResource NullToVisibility}}" />


<TextBlock Text="No selection" 
           Visibility="{Binding SelectedItem, Converter={StaticResource NullToVisibility}, ConverterParameter=Inverse}" />
BooleanToStringConverter

<TextBlock Text="{Binding IsActive, Converter={StaticResource BooleanToString}}" />


<TextBlock Text="{Binding IsOnline, Converter={StaticResource BooleanToString}, ConverterParameter='Online|Offline'}" />


<converters:BooleanToStringConverter x:Key="YesNoConverter" TrueString="Yes" FalseString="No" />
<TextBlock Text="{Binding IsConfirmed, Converter={StaticResource YesNoConverter}}" />
EnumToVisibilityConverter

<TextBlock Text="Grid View Active" 
           Visibility="{Binding ViewMode, Converter={StaticResource EnumToVisibility}, ConverterParameter=Grid}" />
EnumToBooleanConverter

<RadioButton Content="Grid View" 
             IsChecked="{Binding ViewMode, Converter={StaticResource EnumToBoolean}, ConverterParameter=Grid}" />
<RadioButton Content="List View" 
             IsChecked="{Binding ViewMode, Converter={StaticResource EnumToBoolean}, ConverterParameter=List}" />
InverseBooleanConverter

<CheckBox Content="Disabled" 
          IsChecked="{Binding IsEnabled, Converter={StaticResource InverseBoolean}}" />
InverseBooleanToVisibilityConverter

<TextBlock Text="Hidden when true" 
           Visibility="{Binding IsLoading, Converter={StaticResource InverseBooleanToVisibility}}" />

Converter Details

BooleanToVisibilityConverter

  • Purpose: Converts boolean values to Visibility
  • Behavior: True �� Visible, False �� Collapsed
  • Inversion: Supports "Inverse" parameter
  • ConvertBack: Supported

StringToVisibilityConverter

  • Purpose: Shows/hides elements based on string content
  • Behavior: Non-empty �� Visible, Empty/Null �� Collapsed
  • Inversion: Supports "Inverse" parameter
  • ConvertBack: Not supported

NullToVisibilityConverter

  • Purpose: Shows/hides elements based on null state
  • Behavior: Non-null �� Visible, Null �� Collapsed
  • Inversion: Supports "Inverse" parameter
  • ConvertBack: Not supported

BooleanToStringConverter

  • Purpose: Converts boolean values to custom text
  • Behavior: Configurable through properties or parameter
  • Parameter Format: "TrueString|FalseString"
  • Properties: TrueString, FalseString
  • ConvertBack: Supported

EnumToVisibilityConverter

  • Purpose: Shows elements based on enum value matching
  • Parameter: Target enum value as string
  • ConvertBack: Not supported

EnumToBooleanConverter

  • Purpose: RadioButton binding with enums
  • Parameter: Target enum value as string
  • ConvertBack: Supported

InverseBooleanConverter

  • Purpose: Simple boolean inversion
  • ConvertBack: Supported

InverseBooleanToVisibilityConverter

  • Purpose: Boolean to Visibility with built-in inversion
  • Properties: HiddenVisibility (Collapsed/Hidden)
  • ConvertBack: Supported

Design Principles

  • Consistency: All converters follow the same naming and parameter conventions
  • Flexibility: Support for both properties and parameters for customization
  • Reliability: Proper null handling and fallback values
  • Performance: Efficient implementations with minimal overhead

Requirements

  • .NET 8
  • WPF Framework

License

MIT License - see the main Mythosia project for details.

Contributing

This project is part of the larger Mythosia ecosystem. Please refer to the main repository for contribution guidelines.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.0 200 7/16/2025