我有一些包含在資源引用頁面中的樣式。WinRT XAML在DataTemplate中應用樣式
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
我爲TextBlock
,Button
等命名樣式當使用它們時,一切工作正常。
當我嘗試在ItemsControl
的DataTemplate
內使用它們時,它們不會被應用。
<ItemsControl>
<ItemsControl.ItemsPanel>
<StackPanel Orientation="Horizontal" />
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="blah" Style="{StaticResource MyTextBlockStyle}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
如何我可以得到從另一個文件包含的命名風格在裏面工作我DataTemplate
像它在其他地方在網頁上?
我的所有代碼都在幾個項目使用的另一個程序集中。在另一個程序集中爲單個頁面設置應用程序設置xaml似乎並不合理。 –
談到不同的集會,你嘗試[這](http://blogs.msdn.com/b/madenwal/archive/2015/02/09/how-to-link-style-resource-dictionaries-located-in - 不同的組件功能於winrt.aspx)? –
我有'Shared.dll'。這個程序集包含'Page.xaml'和'MyStyles.xaml'。還有另一個應用程序包含此程序集。它適用於頁面上的所有內容,直到ItemsControl的'DataTemplate'內部。 –