menu

WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class BoolToObjectConverter - WinUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class BoolToObjectConverter

    This class converts a boolean value into an other object. Can be used to convert true/false to visibility, a couple of colors, couple of images, etc.

    Inheritance
    System.Object
    BoolToObjectConverter
    BoolToVisibilityConverter
    Implements
    Microsoft.UI.Xaml.Data.IValueConverter
    Namespace: Syncfusion.UI.Xaml.Core
    Assembly: Syncfusion.Core.WinUI.dll
    Syntax
    public class BoolToObjectConverter : DependencyObject, IValueConverter

    Constructors

    BoolToObjectConverter()

    Declaration
    public BoolToObjectConverter()

    Fields

    FalseValueProperty

    Identifies the FalseValue property.

    Declaration
    public static readonly DependencyProperty FalseValueProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    TrueValueProperty

    Identifies the TrueValue property.

    Declaration
    public static readonly DependencyProperty TrueValueProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    Properties

    FalseValue

    Gets or sets the value to be returned when the boolean is false

    Declaration
    public object FalseValue { get; set; }
    Property Value
    Type
    System.Object

    TrueValue

    Gets or sets the value to be returned when the boolean is true

    Declaration
    public object TrueValue { get; set; }
    Property Value
    Type
    System.Object

    Methods

    Convert(Object, Type, Object, String)

    Convert a boolean value to an other object.

    Declaration
    public object Convert(object value, Type targetType, object parameter, string language)
    Parameters
    Type Name Description
    System.Object value

    The source data being passed to the target.

    System.Type targetType

    The type of the target property, as a type reference.

    System.Object parameter

    An optional parameter to be used to invert the converter logic.

    System.String language

    The language of the conversion.

    Returns
    Type Description
    System.Object

    The value to be passed to the target dependency property.

    ConvertBack(Object, Type, Object, String)

    Convert back the value to a boolean

    Declaration
    public object ConvertBack(object value, Type targetType, object parameter, string language)
    Parameters
    Type Name Description
    System.Object value

    The target data being passed to the source.

    System.Type targetType

    The type of the target property, as a type reference (System.Type for Microsoft .NET, a TypeName helper struct for Visual C++ component extensions (C++/CX)).

    System.Object parameter

    An optional parameter to be used to invert the converter logic.

    System.String language

    The language of the conversion.

    Returns
    Type Description
    System.Object

    The value to be passed to the source object.

    Remarks

    If the value parameter is a reference type, TrueValue must match its reference to return true.

    Examples

    Refer to the following code example.

    [XAML]

    <StackPanel>
      <StackPanel.Resources>
          <core:BoolToObjectConverter x:Key="boolToObjectConverter" TrueValue="16" FalseValue="14"/>
       </StackPanel.Resources>
       <CheckBox x:Name="checkBox1"/>
       <TextBlock Text="Apple" FontSize="{Binding IsChecked,ElementName=checkBox1, Converter={StaticResource boolToObjectConverter}}"/>         
    </StackPanel>

    Implements

    Microsoft.UI.Xaml.Data.IValueConverter
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved