-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding Enum Values as ItemsSource in ComboBox not working #3875
Comments
@stevenbrix or @Scottj1s this sounds like a cswinrt issue to me |
@StephenLPeters Any work around solution for this? |
@stevenbrix can you weigh in? |
sounds like this issue: |
@Berkunath, could you convert the enum values to a list of string: protected override object ProvideValue()
{
var values = Enum.GetNames(EnumType);
return values;
} |
This is not a C#/WinRT issue - it repros with UWP apps as well. Appears that the Xaml compiler doesn't property support local types resolution. I tried several other syntax variations, like: These all produced "XamlCompiler error WMC0001: Unknown type 'Type' ..." @RealTommyKlein - any insights here? |
The syntax in the repro is correct (e.g.
Although trying this in the repro project, it looks like there's another issue in the framework where it doesn't handle enums correctly. Using @stevenbrix's suggestion, I was able to get it working.
|
This is not a fix. It's not even a useable workaround. Binding to an Enum should be a single attribute in a XAML element, not a final project in a com sci course. I have the same problem with an observable collection of POCOs that uses an Enum property as the "SelectedValue". The same code works great if I replace the Enum with the integer value, but that's not a work-around either as I have a lot of Enums. What is the status of this issue? |
I think this is still important (re #8638) |
Binding enum Values as ItemsSource in ComboBox not working
I have several enum type in my library and trying to display the enum values in WinUI Desktop ComboBox by get collection using Enum.GetValues by passing Type to EnumValuesExtension class. It works for enum from Microsoft.UI.Xaml, But enum from my library not works.
Observed Items:
Steps to reproduce the bug
Comment out the SizeMode and Shape ComboBox and run the sample. Sample run without crash and display the Horizontal Alignment values in ComboBox. But Running the sample with Shape and SizeMode leads to Crash.
Steps to reproduce the behavior:
Expected behavior
Shape and SizeMode Enum values need to be displayed in ComboBox
NuGet package version:
[Microsoft.WinUI 3.0.0-preview3.201113.0]
Sample :
ComboBoxwithEnumvalues.zip
The text was updated successfully, but these errors were encountered: