I have a case,
public class dictLanguage
{
public string EnglishText { get; set; }
public string FinnishText { get; set; }
}
IEnumerable<dictLanguage> result1 = from ....select new dictLanguage{ EnglishText=... };
IEnumerable<dictLanguage> result2 = from ....select new dictLanguage{ FinnishText=... };
LstBox.DataContext = result1
In Xaml, I have
<listbox ItemsSource="{Binding}">
...
<TextBlock Text="{Binding EnglishText}">
<TextBlock Text="{Binding FinnishText}">
...
</listbox>
I am reading English text from one xml file into “result1” and Finnish text from another xml file into “result2”, but I can set only one ItemSource to ListBox. I have tried hard, but can’t find out any solution. I want to display both values of “dictLanguage”, which are being taken from two different XML files.
Looking for ANY solution,
- Either I can merge result1 and result2
- Or, Read the two xml files simultaneouly, which Iamunable toread using “from…select” clause
- Or, Binding both, result1 and result2 to the listbox
- Or, any possible, and better solution
Could anyone tell me the solution please? – Thanks!
You can’t bind two ItemsSources to a ListBox. Correct and easy way would be to combine data from 2 xml files into one object set (containing all translations). You can write:
Please, read this link on more info for combining multiple sources.