So I was trying to make a Generic IValueConverter
that I could use in a DataGrid
binding where I would send an integer value and an enum type to convert that integer to that enum type and return a string value from the resource file. But what I couldn't do is pass the enum type to the converter because I couldn't reference my enum in my xaml code. This is the reference that I tried:
I want to reference (UserStatus
) which is inside a class named ERPConstants
in the namespace ERPProject._AppControl._BAL._Core._Constants
.
I tried this in my code:
<UserControl x:Class="ERPProject._AppUI._Users.UsersControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Constants="clr-namespace:ERPProject._AppControl._BAL._Core._Constants">
<Grid>
<DataGrid Name="dgUsers" Grid.Row="1">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Status" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label HorizontalAlignment="Left" Content="{Binding Status, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Constants:UserStatus}}"></Label>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>
but it says UserStatus
does not exist in the namespace. I also tried to include ERPConstants
in the xmlns:Constants
above and didn't work. Can anyone help in that?