Flem100@live.dk
Topic Author
Posts: 18
Joined: 16 Jan 2019, 23:16

ComboBox Itemssource

11 Aug 2021, 13:08

Hello there

In this case I am using codebehind and no viewmodel

I am using ItemsSource = a dictionary of type Dictionary<MyEnum, string>();

If I use a list, it works just fine and it's not that the rows are just looks empty, it looks like the combobox is totally empty.

Works fine in Blend-version, but in Noesis it doesn't. The elements are not shown in the combobox. I get no error, and if I instead just use comboBox.Items.Add(item) for each item, it works.
Is there something with the ItemsSource property in Noesis that I should have known?
I am not using Binding anywhere and I have not set DataContext.
<ComboBox x:Name="ddl_SearchType" DisplayMemberPath="Value" SelectedValuePath="Key" SelectionChanged="ddl_SearchType_SelectionChanged" />
            ComboBox ddl_SearchType;
            ddl_SearchType = this.FindName(nameof(ddl_SearchType)) as ComboBox;

            //ddl_SearchType.DisplayMemberPath = "Value";
            //ddl_SearchType.SelectedValuePath = "Key";
            ddl_SearchType.ItemsSource = searchTypeEnumDictionary;
            //foreach (var item in searchTypeEnumDictionary)
            //{
            //    ddl_SearchType.Items.Add(item);
            //}
As you can see I have also tried to set the paths using code, but that makes no difference, I can see that they are detected from xaml, so it's not that.

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 2415
Joined: 22 Dec 2011, 19:20

Re: ComboBox Itemssource

12 Aug 2021, 21:15

In Noesis only types implementing IList can be used as ItemsSource. Could you please report that difference from WPF in our bugtracker?
You can convert the dictionary to an array in the meantime:
Dictionary<MyEnum, string> dict;
ItemsSource = dict.ToArray();

Who is online

Users browsing this forum: No registered users and 5 guests