Alternative to IValueConvert, QuickConverter

https://quickconverter.codeplex.com/

Quick Setup Steps

  1. Add the assembly reference to your project. This can also easily be done using the NuGet package.
  2. Add the namespaces to Quick Converter that it will need to know about (before any xaml that uses it is loaded).
    e.g. In your WPF application's App.xaml.cs file:
    public partial class App : Application
    {
      public App() : base()
      {
        // Setup Quick Converter.
        // Add the System namespace so we can use primitive types (i.e. int, etc.).
        QuickConverter.EquationTokenizer.AddNamespace(typeof(object));
        // Add the System.Windows namespace so we can use Visibility.Collapsed, etc.
        QuickConverter.EquationTokenizer.AddNamespace(typeof(System.Windows.Visibility));
      }
    }
  3. Add the Quick Converter namespace to your xaml files so you can reference it.
    xmlns:qc="clr-namespace:QuickConverter;assembly=QuickConverter"

Now you can
<Rectangle Width="100" Height="100" Fill="Red" Visibility="{qc:Binding '$P ? Visibility.Visible : Visibility.Collapsed', P={Binding IsShow}}">

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Stop console process using Ctrl+C.