![](/img/trans.png)
[英]Windows Phone 8: Localizing the Tile's display name using AppResources.resx
[英]WP8 Multiple projects share code by Windows Phone Class Library, but can't share AppResources.resx
比方說,我有3個項目: LibClassProj
, Proj1
和Proj2
中的Windows Phone develompment用C#。 Proj1
和Proj2
共享LibClassProj
的代碼。 它工作正常。 現在的問題是,我無法從Proj1
或Proj2
的xaml中獲取LibClassProj
的AppResources.resx中的字符串。
例如,這是來自LibClassProj
的xaml的一部分。
SelectableButtonText="{
Binding Path=LocalizedResources.strTestButtonTitleClose,
Source={StaticResource LocalizedStrings}}"
當我在strTestButtonTitleClose
的AppResources.resx文件中放入strTestButtonTitleClose
時,我無法從Proj1
或Proj2
獲取此字符串(這意味着將Proj1
或Proj2
設置為StartUp項目)。 如果我把它放在Proj1
的AppResources.resx中,當我選擇Proj1
作為StartUp項目時,我可以得到它。 與Proj2
相同。
任何人都知道如何只將字符串放在LibClassProj
的AppResources.resx中,我可以從其他項目訪問它嗎? 謝謝。
您需要從每個項目的App.xaml引用該共享資源:
<Application
...
xmlns:lib="clr-namespace:YourApp.LibClassProj;assembly=YourApp.LibClassProj">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
...
</ResourceDictionary.MergedDictionaries>
<lib:LocalizedStrings x:Key="LocalizedStrings"/>
</ResourceDictionary>
</Application.Resources>
</Application>
然后你應該能夠使用你在Proj1和Proj2中提到的字符串:
<TextBlock Text="{Binding Source={StaticResource LocalizedStrings}, Path=LocalizedResources.strTestButtonTitleClose}"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.