我在Xaml中有一個TextBlock來顯示標題。我曾經設置x:Uid="MyTitle"
,在資源文件中描述。但現在,我的頭銜可以改變。我嘗試在我的.cs文件中綁定一個title變量(並且我們不能在x:Uid上綁定)。XAML - > C#從C#中的資源更新文本屬性
所以!我試圖直接在C#上改變我的標題,並且...我失敗了。 這裏是我的愛迪:
我的樹
Root
Source
-code.xaml
-code.xaml.cs
Resources
En
-resources.resw
"Mytitle_1.Text", "This is my first title"
"Mytitle_2.Text", "This is the other one"
code.xaml
<TextBlock TextWrapping="Wrap" x:Name="Exemples" FontSize="20" Margin="20, 0, 20, 0" LineHeight="25" MaxLines="2" FontFamily="Segoe UI Light" Height="65"/>
code.xaml.cs
private string GetResources(string key)
{
ResourceLoader rl = ResourceLoader.GetForCurrentView("../Resources");
string resources = rl.GetString(key);
return resources;
}
private void ChangeTitle()
{
if (something)
Exemples.Text = GetResources("Mytitle_1");
else
Exemples.Text = GetResources("Mytitle_2");
}
是的!在我的解決方案中,我忘記了更改ResourceLoader loader = new ResourceLoader();我編輯你的,你錯過了一個觀點。 – 2015-04-01 12:59:11
這適用於Windows商店應用程序。 8 – 2015-04-02 03:21:50