簡體   English   中英

我可以存儲字符串嗎? <Application.Resources> 並綁定它?

[英]Can i store string in <Application.Resources> and bind to it?

我在幾個頁面上使用微軟的AdControl ......但是為了簡化它我想將ApplicationId存儲一次並將其作為資源讀取。

是否可以在App.xaml中使用然后在控件中設置綁定到它? 但是怎么樣?

使用"{StaticResource name}"就像使用<Page.Resources>

要存儲資源,創建一個新的<ResourceDictionary><ResourceDictionary.MergedDictionaries>把你的資源在。

例如:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>

            <!-- 
                Styles that define common aspects of the platform look and feel
                Required by Visual Studio project and item templates
             -->
            <ResourceDictionary Source="Common/StandardStyles.xaml"/>
            <ResourceDictionary>
                <x:String x:Key="Foo">Bar</x:String>
            </ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM