我在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