Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

How can the category name be dynamically switched?

Open
#1,807 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp

Research direction

Start with PropertyGrid_PreparePropertyItem, ApplyPropertyItemLocalization, and RefreshPropertyGrid from the issue example, then reproduce switching the selected language while the property grid is displayed. Verify whether the category value is refreshed as parameter names and descriptions are, and consider the work done when category names update in real time after the language change.

Written by the indexing model from the issue text.

Description

How can the category name be dynamically switched?
I need to switch between multiple languages.
However, it was found that the category names could not be refreshed in real time.
Parameter names and parameter descriptions are acceptable.
please help me . Thank you.

private void PropertyGrid_PreparePropertyItem(object sender, Xceed.Wpf.Toolkit.PropertyGrid.PropertyItemEventArgs e)
{
if (e?.PropertyItem is not PropertyItem propertyItem) return;

 PropertyDescriptor? propertyDescriptor = propertyItem.PropertyDescriptor;

 if (propertyDescriptor == null)
     return;

 ApplyPropertyItemLocalization(propertyItem, propertyDescriptor);

}

private static void ApplyPropertyItemLocalization(PropertyItem propertyItem,PropertyDescriptor propertyDescriptor)
{
LocalizedDisplayNameAttribute? displayNameAttribute =propertyDescriptor.Attributes[typeof(LocalizedDisplayNameAttribute)]as LocalizedDisplayNameAttribute;

 if (displayNameAttribute != null)
 {
     propertyItem.DisplayName =LocalizationResourceHelper.GetString(displayNameAttribute.ResourceKey,displayNameAttribute.ResourceKey);
 }

 LocalizedDescriptionAttribute? descriptionAttribute =propertyDescriptor.Attributes[typeof(LocalizedDescriptionAttribute)]as LocalizedDescriptionAttribute;

 if (descriptionAttribute != null)
 {
     propertyItem.Description =LocalizationResourceHelper.GetString(descriptionAttribute.ResourceKey,descriptionAttribute.ResourceKey);
 }

 LocalizedCategoryAttribute? categoryAttribute =propertyDescriptor.Attributes[typeof(LocalizedCategoryAttribute)]as LocalizedCategoryAttribute;

 if (categoryAttribute != null)
 {
     propertyItem.Category =LocalizationResourceHelper.GetString(categoryAttribute.ResourceKey,categoryAttribute.ResourceKey);
 }

}

private void RefreshPropertyGrid()
{
object? oldObject = GlobalPropertyGrid.SelectedObject;

 if (oldObject == null)
     return;

 TypeDescriptor.Refresh(oldObject);
 TypeDescriptor.Refresh(oldObject.GetType());

 

 GlobalPropertyGrid.SetCurrentValue(PropertyGrid.SelectedObjectProperty, null);

 Dispatcher.BeginInvoke(new Action(() =>
 {
     TypeDescriptor.Refresh(oldObject);
     TypeDescriptor.Refresh(oldObject.GetType());

     GlobalPropertyGrid.SetCurrentValue(PropertyGrid.SelectedObjectProperty, oldObject);

     GlobalPropertyGrid.UpdateLayout();
     GlobalPropertyGrid.Update();

 }), DispatcherPriority.ContextIdle);

}

Dominant language
C#
Stars
4.2k
Forks
912
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xceedsoftware/wpftoolkit

All issues in xceedsoftware/wpftoolkit

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.