How to bind ComboBox with Entity Framework Core/XAML/WPF

Dmtr_Grms 331 Reputation points
2022-07-11T12:04:01.13+00:00

I have selected an item Postal Info : Id , Zip Code, Locality, Municipality, County, Country
If I use a normal TextBox I see the value Country coming from the DB and I can update it.
Now I would like to go further and use a COMBOBOX on the field Country that is defined as a FK on my table Country.
I tried to find a solution on the Web and I have done some tests but I don't understand how to bind correctly a COMBOBOX that should work like this:

  1. TextBlock should be filled with the country value from the selected item from my context.
  2. I press the arrow on the ComboBox to have the list of countries recorded in my Country Table
  3. The selected Country is indicated in the TextBlock
  4. I save my selected item Postal info with the new Country code value.

Has someone some docs or examples that could help me? Thanks in advance

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
762 questions
{count} votes