Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7248815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:11:28+00:00 2026-05-28T22:11:28+00:00

I want to localize a presentation and I’m having a brain freeze on this

  • 0

I want to localize a presentation and I’m having a brain freeze on this one. I’m using a markup extension, so instead of having this:

<DataGridTextColumn Header="Number" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />

I want this:

<DataGridTextColumn Header="{Resx Key=Header_Number}" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />

where the markup, which is well tested, will just return the right text for the current culture. But it isn’t working. I assume I need either a HeaderStyle or HeaderTemplate but…

What is the fix?

Cheers,
Berryl

EDIT

By isn’t working I mean it isn’t returning the text “Number” while in English, and instead returning a default value (ie, “#Header_Number).

By is working, I mean that

    <Label FontWeight="Bold" Grid.Row="0" Grid.Column="0" Content="{Resx Key=Label_Amount}"/>

returns “Amount” while in English.

FINAL EDIT

My bad, this is really more a result of the fact that WPF data grid columns to not inherit the DataContext of their parent.

The markup extension has a ResxName property which I like to set once for the entire window:

    resx:ResxProperty.Name="NMoneys.Presentation.Resources.AllocatorView"
    Title="{Resx Key=Window_Title}" 

But since the headers in the data grid aren’t part of the visual tree (although it sure seems they should be!), I have to specifically put the name of the Resx again, as in

            <DataGridTextColumn Header="{Resx ResxName=NMoneys.Presentation.Resources.AllocatorView, Key=ColumnHeader_Number}" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />

I’ve run into this before and seen a few techniques to forward the DC, but in this case it isn’t worth the bother.

Cheers,
Berryl

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:11:29+00:00Added an answer on May 28, 2026 at 10:11 pm

    I assume you have models representating your entities. What I’ve done is used data annotations. Here is the example. Edit: Provided MVVM classes with screenshots

    Model

    using System.ComponentModel.DataAnnotations;
    
    using Silverlight.Infrastructure.Properties;
    
    namespace Silverlight.Infrastructure.Models
    {
        public class Customer
        {
            [Display(ResourceType = typeof(Resources), Name = "CustomerIdHeader")]
            public int Id { get; set; }
    
            // There must be an entry CustomerNameHeader in the resources else it 
            // will throw an exception
            [Display(ResourceType = typeof(Resources), Name = "CustomerNameHeader")]
            public string Name { get; set; }
        }
    }
    

    The header content will then automatically bind to the display of the property.

    ViewModel

    using Silverlight.Infrastructure.Models
    
    namespace Silverlight.ModuleA.ViewModels
    {
        //Prism namespaces
        public class CustomerViewModel : NotificationObject
        {
            public CustomerViewModel()
            {   
                // service for my customers.
                CustomeService customerService = new CustomerService();
                Customers = customerService.GetCustomers()
            }   
    
            public ObservableCollection<Customer> Customers {get;set;}
        }
    }
    

    View

    <UserControl>
        <Grid x:Name="LayoutRoot">
            <data:DataGrid x:Name="CustomerGrid" ItemsSource="{Binding Customers}" AutoGenerateColumns="False" >
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Binding="{Binding Id, Mode=TwoWay}" />
                            <data:DataGridTextColumn Binding="{Binding Name, Mode=TwoWay}"/>
                            <data:DataGridTextColumn Binding="{Binding Surname, Mode=TwoWay}"/>
                            <data:DataGridTextColumn Binding="{Binding Company, Mode=TwoWay}"/>
                        </data:DataGrid.Columns>
                </data:DataGrid>
        </Grid>
    </UserControl>
    

    The DataGrid in the program!

    And then the resources in the typeof(StringLibrary)

    Resource File

    As you can see the Name of the display is equal to the ResourceKey in the resources file. I came up with the annotations first when about 2-3 weeks ago when I was developing and testing with XML. But things like AutoMapper can map your objects to pocos like these or you can even Use WCF RIA services and you can have similiar annotations. WCF RIA is actually the one who is using them, but I just use them in a different way.

    There might be a few tricks here and there to accomplish this. But when you do, you really get an easy solution.

    I hope I’ve provided enough information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Spark view engine, and want to localize the website. The methods
Does anyone know how to localize date ranges using C#? In particular, I want
I want to localize my iOS project in xcode4 . In xcode4 this seems
I want to localize my app in 3 languages: english, russian and the one
I want to localize a program I already written.. It's fairly big (almost 50k
I want to localize / globalize the fields on my Login page. I am
I'm developping a little application in WPF and I want to localize my resources.
In order to localize strings used within my javascript, I want scan all my
This code isn't localized: Enum.GetNames(typeof(DayOfWeek)) I want a method that returns a list of
want to know why String behaves like value type while using ==. String s1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.