Windows icon indicating copy to clipboard operation
Windows copied to clipboard

Windows.Foundation.IRefrence1 when using EnumValues

Open ghost1372 opened this issue 2 years ago • 3 comments

Describe the bug

Hi, i am using EnumValues for displaying Enum into ComboBox:

<ComboBox xmlns:enums="using:Microsoft.UI.Xaml"
          xmlns:ui="using:CommunityToolkit.WinUI"
          ItemsSource="{ui:EnumValues Type=enums:TextAlignment}"
          SelectedItem="{x:Bind settings:Helper.Settings.TextAlignment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

and this is result:

image

Steps to reproduce

try this:
<ComboBox xmlns:enums="using:Microsoft.UI.Xaml"
          xmlns:ui="using:CommunityToolkit.WinUI"
          ItemsSource="{ui:EnumValues Type=enums:TextAlignment}"
          SelectedItem="{x:Bind settings:Helper.Settings.TextAlignment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

Expected behavior

showing enum like Center Left Right ...

Screenshots

No response

Code Platform

  • [ ] UWP
  • [X] WinAppSDK / WinUI 3
  • [ ] Web Assembly (WASM)
  • [ ] Android
  • [ ] iOS
  • [ ] MacOS
  • [ ] Linux / GTK

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 10 21H2 (Build 19044)
  • [ ] Windows 10 22H2 (Build 19045)
  • [X] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Windows 10, version 2104 (Build 20348)
  • [X] Windows 11, version 22H2 (Build 22000)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Additional context

No response

Help us help you

No, I'm unable to contribute a solution.

ghost1372 avatar Oct 19 '23 10:10 ghost1372

@michael-hawker i found out that if enum is A, B, C... everythings works fine like this: public enum NavigationViewPaneDisplayMode { Auto, Left, Top, LeftCompact, LeftMinimal }

but if enum is A = 0, B = 1, C = 2,.... not working and i see Windows.Foundation.IRefrence1

 public enum TextAlignment
 {
     Center = 0,
     Left = 1,
     Start = 1,
     Right = 2,
     End = 2,
     Justify = 3,
     DetectFromContent = 4
 }

ghost1372 avatar Oct 19 '23 10:10 ghost1372

i found a solution:

<ComboBox.ItemTemplate>
    <DataTemplate x:DataType="enums:TextAlignment">
        <TextBlock Text="{x:Bind}" />
    </DataTemplate>
</ComboBox.ItemTemplate>

but anyway this issue should be fixed

ghost1372 avatar Oct 19 '23 10:10 ghost1372

Might be related https://github.com/microsoft/microsoft-ui-xaml/issues/4266

Lightczx avatar Nov 09 '23 07:11 Lightczx