<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<XmlDataProvider x:Key="Lookups">
<x:XData>
<ComboBoxItems xmlns="">
<Salutations>
<Item>Mr.</Item>
<Item>Mrs.</Item>
<Item>Ms.</Item>
</Salutations>
<States>
<Item>AL</Item>
<Item>AK</Item>
<Item>CA</Item>
<Item>CT</Item>
</States>
<Wizards>
<Item>Gandalf</Item>
<Item>Radagast</Item>
<Item>Pallando</Item>
<Item>Saruman</Item>
</Wizards>
</ComboBoxItems>
</x:XData>
</XmlDataProvider>
</Page.Resources>
<StackPanel>
<ComboBox ItemsSource="{Binding Source={StaticResource Lookups}, XPath=ComboBoxItems/Salutations/*}"/>
<ComboBox ItemsSource="{Binding Source={StaticResource Lookups}, XPath=ComboBoxItems/States/*}"/>
<ComboBox ItemsSource="{Binding Source={StaticResource Lookups}, XPath=ComboBoxItems/Wizards/*}"/>
</StackPanel>
</Page>
Un avantage de cette approche est que vous pouvez maintenir complètement les éléments séparément du XAML si vous avez besoin - vous pouvez les stocker dans un document XML externe et charger le XmlDataProvider
au moment de l'exécution si vous avez besoin.