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

How to localize the DisplayContent attribute in XAML??

3 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 04 Jun 2010, 12:27 AM
Hi,

Can someone tell me how to localize the DisplayContent attribute for the GroupDescriptor element in XAML?

This works but is not localized...
 <telerik:GroupDescriptor Member="MyObject" DisplayContent="My GroupBy Content" SortDirection="Ascending" />

This does NOT work and instead shows "System.WIndows.Data.Binding" as the label.
 <telerik:GroupDescriptor Member="MyObject" DisplayContent="{Binding Path=Strings.MyLocalizedLabel, Source={StaticResource resourceWrapper}}" SortDirection="Ascending" /> This same code works perfectly with a TextBlock control. 

I've not found any posts on this. So be good to know if this is catered for with this object.

Thanks

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Jun 2010, 12:04 PM
Hello Simon,

There are a couple of possibilities here. The first and most probably the easiest on is to define the group descriptor and set the value for the DisplayContent property directly from your Resources with LocalizationManager:

myDescriptor.DisplayContent = DE.MyGroupByContent;

Here DE is the name of your Resource file.
Another approach is to listen to the event Grouping and again to set the value of DisplayContent in the above way:
this.ordersGrid.Grouping += new System.EventHandler<GridViewGroupingEventArgs>(ordersGrid_Grouping);
  
void ordersGrid_Grouping(object sender, GridViewGroupingEventArgs e)
   {
    e.GroupDescriptor.DisplayContent = DE.MyGroupByContent;
   }


Furthermore, you can predefine the template of the group row and to define there the localization string.

I hope that helps.


Greetings,
Maya
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Simon
Top achievements
Rank 1
answered on 08 Jun 2010, 01:58 AM
Thanks Maya,

I've tried both options but in every case at runtime it says the GroupDescriptor is null and throws a NullReferenceException.
Did you test this yourself? Perhaps I'm doing something wrong. We've had a few of us check it and I don't think we are.

Also to be consistent with the way we're using resource strings throughout the rest of the application, is there a way I can do this in XAML?

Thanks Simon
0
Maya
Telerik team
answered on 08 Jun 2010, 02:04 PM
Hello Simon,

Both solutions I have suggested to you are being tested and working. Do you add the appropriate strings in the Resource file? You can find more detail information about Localization in our online documentation and demos.
As for the possible way of setting the DisplayContent in xaml, you need to set the DefaultResourceManager in App.xaml.cs to point to your resource file:

LocalizationManager.DefaultResourceManager = ES.ResourceManager;

 and then to predefine the template for the GridViewGroupPanelItemTemplate.
<telerik:GridViewGroupPanelCell SortDirection="{Binding SortDirection}"  telerik:LocalizationManager.ResourceKey="{Binding DisplayContent}"/>

Thus when grouping according to a certain column its DesplayContent equivalent will appear in the GroupBy element.
I am sending you a sample project demonstrating the proposed solution.


Best wishes,
Maya
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Simon
Top achievements
Rank 1
Answers by
Maya
Telerik team
Simon
Top achievements
Rank 1
Share this question
or