https://github.com/dwndland/chapter.net.wpf.converters
Chapter.Net.WPF.Converters provides a bunch of useful converters to be used in XAMLs.
https://github.com/dwndland/chapter.net.wpf.converters
converter csharp wpf
Last synced: 6 months ago
JSON representation
Chapter.Net.WPF.Converters provides a bunch of useful converters to be used in XAMLs.
- Host: GitHub
- URL: https://github.com/dwndland/chapter.net.wpf.converters
- Owner: dwndland
- License: mit
- Created: 2024-12-01T16:54:34.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-01T16:55:23.000Z (about 1 year ago)
- Last Synced: 2025-04-08T16:53:44.040Z (9 months ago)
- Topics: converter, csharp, wpf
- Language: C#
- Homepage:
- Size: 193 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# Chapter.Net.WPF.Converters Library
## Overview
Chapter.Net.WPF.Converters is a library that offers a comprehensive collection of ready-to-use value converters for common data binding scenarios in WPF applications.
## Features
- **Override** Override any converter to change their behavior.
- **ValueConverterGroup** Calls one converter after another by passing the result of the previous as a value to the second.
- **MultiValueConverterGroup** Calls the EntryConverter and then one converter after another by passing the result of the previous as a value to the second.
- **BooleanToBooleanConverter** Converts a single boolean or a list of booleans to another single boolean representation.
- **BooleanToIntegerConverter** Converts a single boolean or a list of booleans to an integer representation.
- **BooleanToVisibilityConverter** Converts a single boolean or a list of booleans into a Visibility representation.
- **CharacterCheckToBooleanConverter** Executes a check on a single character or list of characters and returns a boolean representation of that result.
- **CharacterCheckToVisibilityConverter** Executes a check on a single character or list of characters and returns a Visibility representation of that result.
- **ConcatenateStringConverter** Concatenates all given values to a single string with an optional configurable separator.
- **DateOnlyToStringConverter** Formats a single DateOnly to a string.
- **DateTimeToStringConverter** Formats a single DateTime to a string.
- **DateTimeUtcConverter** Converts the given date time to universal or local time.
- **DoubleComparisonToBooleanConverter** Executes a comparison on a single double or list of doubles to a boolean representation.
- **DoubleComparisonToVisibilityConverter** Executes a comparison on a single Visibility or list of Visibilities to a boolean representation.
- **DoubleMathConverter** Does a simple calculation with the given value as double.
- **DoubleToStringConverter** Formats a double to string.
- **DoubleToThicknessConverter** to build a Thickness object by a given single double value.
- **EqualsToBooleanConverter** Compares a single value to a variable or a list of values to each other and returns its boolean representation.
- **EqualsToVisibilityConverter** Compares a single value to a variable or a list of values to each other and returns its Visibility representation.
- **IntegerComparisonToBooleanConverter** Executes a comparison on a single integer or list of integers to a boolean representation.
- **IntegerComparisonToVisibilityConverter** Executes a comparison on a single integer or list of integers to a Visibility representation.
- **IntegerMathConverter** Does a simple calculation with the given value as integer.
- **IntegerToBooleanConverter** Converts a single integer or a list of integers to a boolean representation.
- **IntegerToStringConverter** Formats an integer to string.
- **IsLastItemInListConverter** Checks if the given item container is the last in the list.
- **IsNullToBooleanConverter** Checks if a single object or a list of objects is null and returns a boolean representation.
- **IsNullToVisibilityConverter** Checks if a single object or a list of objects is null and returns a Visibility representation.
- **NumberCheckToBooleanConverter** Executes a check on a single number or list of numbers and returns a boolean representation of that result.
- **NumberCheckToVisibilityConverter** Executes a check on a single number or list of numbers and returns a Visibility representation of that result.
- **ObjectToTypeConverter** Returns the type of the given object.
- **PathToStringConverter** Reads out part of a given path.
- **RoundingConverter** Rounds the given value as double.
- **StringCheckToBooleanConverter** Executes a check on a single string or list of strings and returns a boolean representation of that result.
- **StringCheckToVisibilityConverter** Executes a check on a single string or list of strings and returns a Visibility representation of that result.
- **StringToLowerConverter** Converts the given value as string to lower.
- **StringToUpperConverter** Converts the given value as string to upper.
- **TimeOnlyToStringConverter** Formats a single TimeOnly to a string.
- **ValueToPathConverter** Combines all given strings into a path.
## Getting Started
1. **Installation:**
- Install the Chapter.Net.WPF.Converters library via NuGet Package Manager:
```bash
dotnet add package Chapter.Net.WPF.Converters
```
2. **Override:**
- Override any converter to change their behavior.
```csharp
public class MyConcatenateStringConverter : ConcatenateStringConverter
{
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
values = values.Distinct().ToArray();
var converted = base.Convert(values, targetType, parameter, culture);
return "Result: " + converted;
}
}
```
3. **ValueConverterGroup**
- Calls one converter after another by passing the result of the previous as a value to the second.
```xaml
```
4. **MultiValueConverterGroup**
- Calls the EntryConverter and then one converter after another by passing the result of the previous as a value to the second.
```xaml
```
5. **BooleanToBooleanConverter**
- Converts a single boolean or a list of booleans to another single boolean representation.
```xaml
```
```xaml
```
6. **BooleanToIntegerConverter**
- Converts a single boolean or a list of booleans to an integer representation.
```xaml
```
```xaml
```
7. **BooleanToVisibilityConverter**
- Converts a single boolean or a list of booleans into a Visibility representation.
```xaml
```
```xaml
```
8. **CharacterCheckToBooleanConverter**
- Executes a check on a single character or list of characters and returns a boolean representation of that result.
```xaml
```
```xaml
```
9. **CharacterCheckToVisibilityConverter**
- Executes a check on a single character or list of characters and returns a Visibility representation of that result.
```xaml
```
```xaml
```
10. **ConcatenateStringConverter**
- Concatenates all given values to a single string with an optional configurable separator.
```xaml
```
11. **DateOnlyToStringConverter**
- Formats a single DateOnly to a string.
```xaml
```
12. **DateTimeToStringConverter**
- Formats a single DateTime to a string.
```xaml
```
13. **DateTimeUtcConverter**
- Converts the given date time to universal or local time.
```xaml
```
14. **DoubleComparisonToBooleanConverter**
- Executes a comparison on a single double or list of doubles to a boolean representation.
```xaml
```
```xaml
```
15. **DoubleComparisonToVisibilityConverter**
- Executes a comparison on a single Visibility or list of Visibilities to a boolean representation.
```xaml
```
```xaml
```
16. **DoubleMathConverter**
- Does a simple calculation with the given value as double.
```xaml
```
17. **DoubleToStringConverter**
- Formats a double to string.
```xaml
```
18. **DoubleToThicknessConverter**
- Builds a Thickness object by a given single double value.
```xaml
```
```xaml
```
19. **EqualsToBooleanConverter**
- Compares a single value to a variable or a list of values to each other and returns its boolean representation.
```xaml
5
```
```xaml
```
20. **EqualsToVisibilityConverter**
- Compares a single value to a variable or a list of values to each other and returns its Visibility representation.
```xaml
5
```
```xaml
```
21. **IntegerComparisonToBooleanConverter**
- Executes a comparison on a single integer or list of integers to a boolean representation.
```xaml
```
```xaml
```
22. **IntegerComparisonToVisibilityConverter**
- Executes a comparison on a single integer or list of integers to a Visibility representation.
```xaml
```
```xaml
```
23. **IntegerMathConverter**
- Does a simple calculation with the given value as integer.
```xaml
```
24. **IntegerToBooleanConverter**
- Converts a single integer or a list of integers to a boolean representation.
```xaml
```
```xaml
```
25. **IntegerToStringConverter**
- Formats an integer to string.
```xaml
```
26. **IsLastItemInListConverter**
- Checks if the given item container is the last in the list.
```xaml
<Setter Property="Background" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border Background="{TemplateBinding Background}">
<DataGridCellsPresenter />
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource IsLastItemInListConverter}}" Value="True">
<Setter Property="Background" Value="Gray" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
```
27. **IsNullToBooleanConverter**
- Checks if a single object or a list of objects is null and returns a boolean representation.
```xaml
```
```xaml
```
28. **IsNullToVisibilityConverter**
- Checks if a single object or a list of objects is null and returns a Visibility representation.
```xaml
```
```xaml
```
29. **NumberCheckToBooleanConverter**
- Executes a check on a single number or list of numbers and returns a boolean representation of that result.
```xaml
```
```xaml
```
30. **NumberCheckToVisibilityConverter**
- Executes a check on a single number or list of numbers and returns a Visibility representation of that result.
```xaml
```
```xaml
```
31. **ObjectToTypeConverter**
- Returns the type of the given object.
```xaml
```
32. **PathToStringConverter**
- Reads out part of a given path.
```xaml
```
33. **RoundingConverter**
- Rounds the given value as double.
```xaml
```
34. **StringCheckToBooleanConverter**
- Executes a check on a single string or list of strings and returns a boolean representation of that result.
```xaml
```
```xaml
```
35. **StringCheckToVisibilityConverter**
- Executes a check on a single string or list of strings and returns a Visibility representation of that result.
```xaml
```
```xaml
```
36. **StringToLowerConverter**
- Converts the given value as string to lower.
```xaml
```
37. **StringToUpperConverter**
- Converts the given value as string to upper.
```xaml
```
38. **TimeOnlyToStringConverter**
- Formats a single TimeOnly to a string.
```xaml
```
39. **ValueToPathConverter**
- Combines all given strings into a path.
```xaml
```
## Links
* [NuGet](https://www.nuget.org/packages/Chapter.Net.WPF.Converters)
* [GitHub](https://github.com/dwndland/Chapter.Net.WPF.Converters)
## License
Copyright (c) David Wendland. All rights reserved.
Licensed under the MIT License. See LICENSE file in the project root for full license information.