This is a migrated thread and some comments may be shown as answers.

HeaderText update

4 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 31 Mar 2009, 03:20 PM
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:
<telerik:GridViewDataColumn IsFilterable="False" HeaderText="{local:Caption Key=memberNumberShort}" UniqueName="MemberNumber"/> 
 The relevant code of the CaptionExtension class looks like this:
        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


4 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 1
answered on 01 Apr 2009, 07:38 AM
The problem is actually very easy to reproduce: Just try tot change the column's HeaderText at run time when the grid is already being displayed: Nothing happens.
0
Vlad
Telerik team
answered on 01 Apr 2009, 08:12 AM
Hello Christian,

The problem was fixed immediately and the fix will be part of our first service pack (after two weeks).

I've added 1000 Telerik points to your account.

All the best,
Vlad
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Jon Masters
Top achievements
Rank 1
answered on 01 Apr 2009, 01:08 PM
Does the fix for this address the problem with the columns background not updating as detailed in an alternate post?
0
Kalin Milanov
Telerik team
answered on 01 Apr 2009, 07:00 PM
Hello Jon,

Unfortunately those two issues are not related. 
As for your alternate requests please follow the following links:



Greetings,
Kalin Milanov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Christian
Top achievements
Rank 1
Answers by
Christian
Top achievements
Rank 1
Vlad
Telerik team
Jon Masters
Top achievements
Rank 1
Kalin Milanov
Telerik team
Share this question
or