CMarinacci
Topic Author
Posts: 13
Joined: 07 Aug 2017, 02:56

Enum binding different than in WPF (Unity)

01 Mar 2018, 22:24

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
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Enum binding different than in WPF (Unity)

06 Mar 2018, 13:28

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:
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
  YourEnum e = (YourEnum)(int)value;
  //...
}
Or:
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 0 guests