开发者

WPF Populate combo box with multi-table data

I'm w开发者_高级运维orking on a simple WPF example and wanted to expand the example but I'm struggling, I'll explain some background first. I have three tables, people, addresses, and countries. As expected people live at an address, and addresses are located in a specific country.

I'm currently working through using a combo box as a lookup table when creating a new person so that I can select an existing address and it's working great so far. My addresses come out in the format "Street No., Street Name, Postal Code" by use of a ItemsControl.ItemTemplate in my combo box.

I would like to also include the country in the formatted address, however my address table contains just the FK into my countries table. Is it possible that I can reach into my countries table to grab the country name all inside the ItemsControl.ItemTemplate? OR is there a mechanism that I need to understand/research?


Silly me the solution was there all along since my address entity has access to its country through a property.

I simply added another textblock to my ItemsControl.ItemTemplate and bound it to Country.Name

<TextBlock Name="Country" Text="{Binding Path=Country.Name}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜