2011-01-06 66 views

回答

2

您綁定ItemsSource

<ListBox ItemsSource="{Binding ElementName=MyDataSource, Path=Data }"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding MyDescription}" /> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

,並定義一個DataSource稱爲 「MyDataSource」:

<riaControls:DomainDataSource x:Name="MyDataSource"... 

</riaControls:DomainDataSource> 
+0

好它的工作,但我們不能透過的DataContext和資源做到這一點,在Visual定義了樹? – LEE 2011-01-06 16:40:15