Let's say that you have a List that looks like the following
public List<Person> Persons { get; set; }
You set an ItemSource
on a ListBox
to get the data from Persons and for each person in that list, you want to select other items, depending on the social security number.
It is not an option to store the data in the Person, so the Data has to be fetched once the Person is processed in the list.
This will end up looking somewhat like this om XAML
<ListBox Name="myListBox">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Label Content="{Binding Name}"/>
<ComboBox ItemsSource="{Binding MyOtherData}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Now, I want MyOtherData to be a Method which will return a set of data, depending on the current person, so I would just like to have a Method, takin an argument like the social security-number.
How could this look?
I am kind of new to the WPF - XAML stuff and if this is a design flaw, please suggest other solutions on that aswell.