Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF XAML pass to ConverterParameter array of enums

Tags:

c#

enums

wpf

xaml

I have enum

public enum DocumentTypes
{
    First, Second, Third, Fourth
}

How to pass values of enum to <sys:Enum></sys:Enum>

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1.Converters"
xmlns:enums="clr-namespace:WpfApplication1.Enums"
xmlns:sys="clr-namespace:System;assembly=mscorlib"

       <Label Content="Test2">
            <Label.Visibility>
                <MultiBinding Converter="{StaticResource Converter}">
                    <MultiBinding.ConverterParameter>
                        <x:Array Type="{x:Type sys:Enum}">
                            <sys:Enum></sys:Enum>
                        </x:Array>
                    </MultiBinding.ConverterParameter>
                    <Binding ElementName="First" Path="IsChecked" />
                    <Binding ElementName="Second" Path="IsChecked" />
                    <Binding ElementName="Third" Path="IsChecked" />
                    <Binding ElementName="Fourth" Path="IsChecked" />
                </MultiBinding>
            </Label.Visibility>
        </Label>
like image 585
A191919 Avatar asked Oct 17 '25 15:10

A191919


1 Answers

Do this :

    <x:Array Type="{x:Type sys:Enum}">
        <local:DocumentTypes>First</local:DocumentTypes>
        <local:DocumentTypes>Second</local:DocumentTypes>
        <local:DocumentTypes>Third</local:DocumentTypes>
    </x:Array>
like image 91
AnjumSKhan Avatar answered Oct 20 '25 06:10

AnjumSKhan