2015-11-30 41 views
0

如果我在XAML定義如如何在XAML集合中引用靜態資源?

<x:String x:Key="HelloString">Hello</x:String> 
<x:String x:Key="GoodbyeString">Goodbye</x:String> 

是什麼將它們添加到一個XAML集合,如ListBox中的語法靜態資源?

我的意圖是做這樣的事情:

<ListBox> 
    <x:String Source="{StaticResource HelloString}"/> 
    <x:String Source="{StaticResource GoodbyeString}"/> 
</ListBox> 

但我錯過了正確的語法。

回答

3

有可能通過使用ContentPresenter

<ListBox> 
    <ContentPresenter Content="{StaticResource HelloString}"/> 
    <ContentPresenter Content="{StaticResource GoodbyeString}"/> 
</ListBox>