Hello
For the localization of my application I have created a custom MarkupExtension called CaptionExtension. I'm using it to set the HeaderText in the WPF RadGridView as follows:
The relevant code of the CaptionExtension class looks like this:
So basically it tries to remember to which DependencyObject (targetObject variable) which DependencyProperty (targetProperty variable) was initially set. This happens in the ProvideValue()-method. Then in the LocalizationContext_CultureChanged()-event handler method, it tries to set the new value using the combination of DependencyObject/DependencyProperty combination.
For the HeaderText property the value of targetObject is of type GridViewDataColumn and the targetProperty is the HeaderText DependencyProperty. I've made sure that is really the case using the debugger.
Unfortunately the correct text is only set initially so during the call of the ProvideValue when the RadGridView is created the first time. Setting the HeaderText in the LocalizationContext_CultureChanged() does not work. There is no exception or anything, just nothing happens, the HeaderText does not change in display.
Any help is welcome.
Regards
Christian
For the localization of my application I have created a custom MarkupExtension called CaptionExtension. I'm using it to set the HeaderText in the WPF RadGridView as follows:
<telerik:GridViewDataColumn IsFilterable="False" HeaderText="{local:Caption Key=memberNumberShort}" UniqueName="MemberNumber"/> |
private void LocalizationContext_CultureChanged(object sender, EventArgs e) { |
if (targetObject != null && targetProperty != null) { |
targetObject.SetValue(targetProperty, LocalizationContext.Instance.Captions[key]); |
} |
} |
public override object ProvideValue(IServiceProvider serviceProvider) { |
var targetHelper = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget)); |
targetObject = targetHelper.TargetObject as DependencyObject; |
targetProperty = targetHelper.TargetProperty as DependencyProperty; |
return LocalizationContext.Instance.Captions[key]; |
} |
So basically it tries to remember to which DependencyObject (targetObject variable) which DependencyProperty (targetProperty variable) was initially set. This happens in the ProvideValue()-method. Then in the LocalizationContext_CultureChanged()-event handler method, it tries to set the new value using the combination of DependencyObject/DependencyProperty combination.
For the HeaderText property the value of targetObject is of type GridViewDataColumn and the targetProperty is the HeaderText DependencyProperty. I've made sure that is really the case using the debugger.
Unfortunately the correct text is only set initially so during the call of the ProvideValue when the RadGridView is created the first time. Setting the HeaderText in the LocalizationContext_CultureChanged() does not work. There is no exception or anything, just nothing happens, the HeaderText does not change in display.
Any help is welcome.
Regards
Christian