【发布时间】:2011-08-04 09:11:11
【问题描述】:
我按照这个例子构建了一个多语言应用程序:How to: Build a Localized Application for Windows Phone。
我成功地将资源数据绑定到这样的文本:
<TextBlock x:Name="ApplicationTitle" Text="{Binding Path=MultiLangResources.Mainpage_Welcome, Source={StaticResource MultiLang}}"/>
我尝试更改Thread.CurrentThread.CurrentUICulture,我可以用代码输出正确的密钥:
ApplicationTitle.Text = LangResource.Mainpage_Welcome;
但是,绑定的文本永远不会更新。
如何让绑定的文本像普通绑定一样更新?
有没有人可以帮我解决这个问题? 我也试过这个,但没有运气。
public class MultiLang : INotifyPropertyChanged
{
public MultiLang()
{
}
private static MLTest.LangResource multiLangResources = new GigapodV2.LangResource();
public MLTest.LangResource MultiLangResources
{
get { return multiLangResources; }
set
{
if (value != multiLangResources)
{
multiLangResources = value;
NotifyPropertyChanged("MultiLangResources");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string property)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
}
【问题讨论】:
标签: xaml data-binding windows-phone-7 multilingual