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 419149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:44:56+00:00 2026-05-12T18:44:56+00:00

The project I am working on has a rich text box that can have

  • 0

The project I am working on has a rich text box that can have it’s font changed to any of the system fonts via a combo box.

We add all the FontFamily objects from “Fonts.SystemFontFamilies” as the ItemsSource of the combo box. We need to be able to show the localized names of these fonts if they exist within each FontFamily.

I’m currently assuming that the text we see displayed for each ComboBoxItem is the Source property of the FontFamily objects we set as the ItemsSource. Is there a simple way to localize this source? I have been able to get the localized names using:

font.FamilyNames.TryGetValue(XmlLanguage.GetLanguage("ja-JP"), out name);

but as FontFamily.Source is readonly, I am unable to assign this new name to the FontFamily objects.

— UPDATE —

We have decided not to use a class that contains a font family due to complications with integrating it with the application. I want to try using a value converter to avoid having to change the underlying code.

I have the following value converter class:

class FontValueConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        FontFamily font = (FontFamily)value;
        string localizedName = font.FamilyNames[XmlLanguage.GetLanguage(culture.Name)];

        if (!String.IsNullOrEmpty(localizedName))
            return localizedName;

        return font.ToString();
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException("ConvertBack not supported");
    }
}

I am trying to bind this to the ComboBoxItem objects. We set the ItemsSource in the code behind file; basically “ItemsSource = collectionOfFonts”. What I want to do is bind my converter to each item in ItemsSource so that it will converter to the localized font family name.

I have been considering the following XAML:

         <Style
            x:Key="ComboBoxItemStyle"
            TargetType="{x:Type ComboBoxItem}">
            <Setter
                Property="Template">
                <Setter.Value>
                    <ControlTemplate
                        TargetType="{x:Type ComboBoxItem}">
                        <ContentPresenter
                            Content="{Binding Source=..., Converter={StaticResource FontValueConverter}}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

However, I am confused as to how I can bind so it retrieves a FontFamily object and converts it to a string to return as the value to be displayed.

Any thoughts?

  • 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-12T18:44:56+00:00Added an answer on May 12, 2026 at 6:44 pm

    We discovered the simplest solution that requires minimal changes to the rest of the application was to instantiate a new FontFamily object using the localized name of the font if available. This was done by creating the following method which returns a new FontFamily object if necessary:

        private FontFamily GetLocalizedFontFamily(FontFamily font)
        {
            string localizedName = font.FamilyNames[XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name)];
            if (!String.IsNullOrEmpty(localizedName))
                return new FontFamily(localizedName);
    
            return font;
        }
    

    Using this approach meant that we only had to alter the code where the items are added to the combo box and required absolutely no changes elsewhere.

    Example of use:

    foreach (FontFamily font in Fonts.SystemFontFamilies)
    {
        FontFamily localizedFont = GetLocalizedFontFamily(font);
        FontFamilyComboBox.Items.Add(localizedFont);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project that has a rich object model with various sets
I have been working on a project that has 2 interfaces - windows forms
Right now a project I'm working on has reached a level of complexity that
I am working on a project that has grown to a decent size, and
I'm working on a project that currently has zero users but we would like
I am working in a project that has two main parts: a class library
I'm working on a C#/ASP.NET project that has all the javascript files in a
I am working on implementing Zend Framework within an existing project that has a
I'm working on a project which has a rich domain-model. Some of my classes
I project I have been working on has now been split between me and

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.