❔ How to bind data to a listbox that doesnt come out of a database?
Title pretty much says it all.
I have the following code but it doesnt work:
17 Replies
What does your code for your data look like?
ideologies is a simple list storing all the ideologies
how/where are you adding data to ideologies?
I've assumed by "doesn't work" you mean that you're not getting any errors/binding errors, just no data showing in the listbox?
Yeah, the list is correctly filled I have checked that
I run this
When starting up the menu window and loading in all the data/settings
Don't know what your Ideology class looks like but no reason why it shouldn't work if your
ideologies
list is populated
That is my ideology class
copied your class and still works for me

That is really weird than
are other bindings on the window working ok? try setting DisplayMemberPath?
Its only this
But it still doesnt work
can you update your margin to 0 and try?
Since
ideologies
is a list, if the data binding is set up before that list is filled, it will show nothing
if you instead make it an ObservableCollection<Ideology>
, you might get better results
InitializeComponent is run as last shouldnt that assure that the list is defined before binding?
¯\_(ツ)_/¯
Fair enough
Will try to make it a observable and hope that works than
using a list as a datasource should work fine, but as said, no reactivity.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.