2009-09-09 15 views

回答

1

没有代码,这是最有价值的你可以AFAIK。

0
<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> 

这种方法的好处是,你可以从XAML完全独立维护的项目,如果你需要 - 你可以将它们存储在外部XML文件中并在运行时加载XmlDataProvider如果您需要。

相关问题