Git Product home page Git Product logo

wpf.converters's Introduction

Wpf.Converters

CI Status NuGet version

This library contains a collection of often used converters to write a WPF based application.

Installation

The recommended way to use this library is via Nuget.

Currently supported frameworks:

  • .NET Framework 3.5 or higher
  • .NET Core 3.0 or higher

Getting started

Import it via:

xmlns:c="clr-namespace:NKristek.Wpf.Converters;assembly=NKristek.Wpf.Converters"

You can use a converter from this library either by using the MarkupExtension*:

<Label Content="{Binding Value}"
       Visibility="{Binding Value, Converter={c:ValueNotNullToVisibilityConverter}}" />

or static instance:

<Label Content="{Binding Value}"
       Visibility="{Binding Value, Converter={x:Static c:ValueNotNullToVisibilityConverter.Instance}}" />

or of course create instances in the views:

<Window.Resources>
    <c:ValueNotNullToVisibilityConverter x:Key="ValueNotNullToVisibilityConverter" />
</Window.Resources>

<Label Content="{Binding Value}"
       Visibility="{Binding Value, Converter={StaticResource ValueNotNullToVisibilityConverter}}" />

You can also use the ValueConverterChain converter*, which executes the given converters in succession. Please note, that the TargetType is only correctly set, when the ValueConversionAttribute is set on the IValueConverter.

<c:ValueConverterChain x:Key="ValueNullToInverseBoolConverter">
    <c:ValueNullToBoolConverter/>
    <c:BoolToInverseBoolConverter/>
</c:ValueConverterChain>

The above use of the ValueConverterChain would be equivalent to the ValueNullToInverseBoolConverter.

*: Only available if target framework is >= .NET 4.0.

Overview

Bool:

  • BoolToInverseBoolConverter
  • ValueNullToBoolConverter
  • ValueNullToInverseBoolConverter
  • StringNullOrEmptyToBoolConverter
  • StringNullOrEmptyToInverseBoolConverter
  • ICollectionNullOrEmptyToBoolConverter
  • ICollectionNullOrEmptyToInverseBoolConverter
  • AllBoolToBoolConverter
  • AllBoolToInverseBoolConverter
  • AnyBoolToBoolConverter
  • AnyBoolToInverseBoolConverter
  • ObjectToStringEqualsParameterToBoolConverter
  • ObjectToStringEqualsParameterToInverseBoolConverter

Visibility:

  • VisibilityToInverseVisibilityConverter
  • BoolToVisibilityConverter
  • BoolToInverseVisibilityConverter
  • ValueNullToVisibilityConverter
  • ValueNullToInverseVisibilityConverter
  • StringNullOrEmptyToVisibilityConverter
  • StringNullOrEmptyToInverseVisibilityConverter
  • ICollectionNullOrEmptyToVisibilityConverter
  • ICollectionNullOrEmptyToInverseVisibilityConverter
  • AllBoolToVisibilityConverter
  • AllBoolToInverseVisibilityConverter
  • AnyBoolToVisibilityConverter
  • AnyBoolToInverseVisibilityConverter
  • ObjectToStringEqualsParameterToVisibilityConverter
  • ObjectToStringEqualsParameterToInverseVisibilityConverter

Other:

  • DateTimeToStringConverter
  • ValueConverterChain

Contribution

If you find a bug feel free to open an issue. Contributions are also appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.