我有一个需要用WPFLocalizationExtension翻译的DataGridComboBoxColumn。
我的视图模型中有一个静态方法,它提供了可用的值:
public static List<ProfileSegmentType> AvailableSegmentTypes
{
get
{
var availableSegmentTypes = new List<ProfileSegmentType>
{
new ProfileSegmentType { Value = ProfileSegmentTypeEnum.Arc },
new ProfileSegmentType { Value = ProfileSegmentTypeEnum.Line },
};
return availableSegmentTypes;
}
}ProfileSegmentType如下所示:
public class ProfileSegmentType
{
public ProfileSegmentTypeEnum Value { get; set; }
public string Label
{
get { return Resources.Localization.ADummyValue; }
}
}我的数据网格列定义如下所示:
<DataGridComboBoxColumn Header="..."
ItemsSource="{Binding Source={x:Static viewModels:ProfileGeometryViewModel.AvailableSegmentTypes}}"
SelectedValueBinding="{Binding SegmentType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Value"
DisplayMemberPath="Label" />现在我得到了标签的翻译(现在是虚拟值)。当然,当我切换语言时,单元格不会更新。当我切换语言时,如何实现单元格内容的更新?(我也尝试使用值转换器,但无法以这种方式工作)
发布于 2015-07-02 16:56:17
在你的评论的帮助下,我可以解决它。我不得不这样修改我的ProfileSegmentType:
public class ProfileSegmentType : INotifyPropertyChanged
{
public ProfileSegmentType()
{
LocalizeDictionary.Instance.PropertyChanged += (e, a) =>
{
if (a.PropertyName == "Culture")
PropertyChanged(this, new PropertyChangedEventArgs("Label"));
};
}
public ProfileSegmentTypeEnum Value { get; set; }
public string Label
{
get { return Common.Resources.Localization.Add; }
}
public event PropertyChangedEventHandler PropertyChanged = (e, a) => {};
}https://stackoverflow.com/questions/31177675
复制相似问题