C# 如何将observablecollection成员连接到应用程序资源(resx)文件
嘿,伙计们,首先我为这个糟糕的解释感到抱歉。我的任务是翻译一个我不久前写的应用程序,通常没有什么特别的 但现在我正处在一个关键时刻。我的应用程序的一个功能是保存历史记录。我为此创建了一个基本类C# 如何将observablecollection成员连接到应用程序资源(resx)文件,c#,silverlight,windows-phone-7,windows-phone-8,C#,Silverlight,Windows Phone 7,Windows Phone 8,嘿,伙计们,首先我为这个糟糕的解释感到抱歉。我的任务是翻译一个我不久前写的应用程序,通常没有什么特别的 但现在我正处在一个关键时刻。我的应用程序的一个功能是保存历史记录。我为此创建了一个基本类 public class GHistoryClass { public GHistoryClass(string act, string icop, string categ, string desc,) { this.m_Action =
public class GHistoryClass
{
public GHistoryClass(string act, string icop, string categ, string desc,)
{
this.m_Action = act;
this.m_IconPath = icop;
this.m_Description = desc;
this.m_Category = categ;
}
public string m_Action { get; set; }
public string m_Description { get; set; }
public string m_Category { get; set; }
public string m_IconPath { get; set; }
}
我正在将历史记录像observeablecollection
一样保存在IsolatedStorage
中。
当语言改变时,我想翻译历史
例如,我不知道如何将m_Action
连接到本地化资源
任何想法都将不胜感激
编辑
我认为应该做的是将AppResources
属性名保存为字符串
因此m_Action=“AppResources.firstaction”
然后我的想法是将其转换为PropertyPath
。
这是一个好主意吗?如何将字符串
转换为对象
名称?将资源(resx)文件添加到项目中时,每个资源都会生成一个属性
internal class MyResources
{
// other properties etc
internal static string SomeLabel
{
get
{
return ResourceManager.GetString("SomeLabel", resourceCulture);
}
}
}
通常,您会像这样使用此资源:
string label = MyResources.SomeLabel;
但你不必这么做。相反,您可以直接访问ResourceManager:
string label = MyResources.ResourceManager.GetString(m_Action);
我花了将近两天的时间寻找,如果你在我身边,我会吻你