microsoft / XamlBehaviors

This is the official home for UWP XAML Behaviors on GitHub.
MIT License
702 stars 112 forks source link

DataTriggerBehavior doesn't support enum comparison #84

Open vborovikov opened 8 years ago

vborovikov commented 8 years ago

It seems that binding DataTriggerBehavior to enum property on a viewmodel doesn't work and breaks other bindings in page/usercontrol too.

I'm trying to bind DataTriggerBehavior to an enum property on a viewmodel and compare it to a string representation of the enum value.

adamhewitt627 commented 8 years ago

Same here. I've worked around it for now with a value converter to get the enum to a string (matching the value name) and then setting Value="EnumsStringValue". It'd be nice for the framework to handle it and get the compile checking.

EddyHaigh commented 2 years ago

Is this going to get fixed? The PR has been in since 2019 and I'm hitting the same issue on WinUI 3 with behaviors.

bogdan-patraucean commented 2 years ago

I encountered the same issue:

This works:

Binding="{x:Bind Color.ToString(), Mode=OneWay}" ComparisonCondition="Equal" Value="{x:Bind local:LabelColor.LightGreen.ToString(), Mode=OneWay}"

This doesn't:

Binding="{x:Bind Color, Mode=OneWay}" ComparisonCondition="Equal" Value="{x:Bind local:LabelColor.LightGreen, Mode=OneWay}"

The only difference is the ToString, this looks like a simple problem to solve, I don't know why such a basic feature is not yet fully supported.