-
- CMarinacci
- Posts: 15
- Joined:
Enum binding different than in WPF (Unity)
If you bind an enum property to the Text property of a TextBlock in NoesisGUI, the Text property is not set to the ToString() value of the enum property, as it is in WPF.
I tried working around this by using an IValueConverter, but the value passed by NoesisGUI to the Convert method is an int instead of an enum.
Is this a bug, or a limitation of NoesisGUI?
Thanks,
Chris
I tried working around this by using an IValueConverter, but the value passed by NoesisGUI to the Convert method is an int instead of an enum.
Is this a bug, or a limitation of NoesisGUI?
Thanks,
Chris
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Enum binding different than in WPF (Unity)
We recently found this bug in the binding and fixed it for the next release.
But the IValueConverter behavior you are seeing is a current limitation of NoesisGUI, enum values are recived as ints in the Convert/ConvertBack methods, but you can easily convert the value knowing the enum type:
Or:
But the IValueConverter behavior you are seeing is a current limitation of NoesisGUI, enum values are recived as ints in the Convert/ConvertBack methods, but you can easily convert the value knowing the enum type:
Code: Select all
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
YourEnum e = (YourEnum)(int)value;
//...
}Code: Select all
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
YourEnum e = (YourEnum)Enum.ToObject(typeof(YourEnum) , value);
//...
}Who is online
Users browsing this forum: No registered users and 4 guests