HeaderText update

5 posts, 0 answers
  1. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 31 Mar 2009 Link to this post

    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


  2. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 01 Apr 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 01 Apr 2009 Link to this post

    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.
  5. Jon Masters
    Jon Masters avatar
    4 posts
    Member since:
    Sep 2008

    Posted 01 Apr 2009 Link to this post

    Does the fix for this address the problem with the columns background not updating as detailed in an alternate post?
  6. Kalin Milanov
    Admin
    Kalin Milanov avatar
    447 posts

    Posted 01 Apr 2009 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready