Hi,
I define PropertyGrid in XAML next way:
<propgrid:PropertyGrid x:Name="PropertiesUserControl" IsSummaryVisible="True" AreNestedCategoriesSupported="True"
IsEnabled="True" AreDefaultSortDescriptionsEnabled="False"
AreCategoriesAutoExpanded="False" SelectedObject="{Binding SelectedObject}"
IsAsynchronous="True">
</propgrid:PropertyGrid>
This way I define property to be shown in PropertyGrid:
[LocalizedCategory("Category"),
LocalizedDisplayName("DisplaySomeProperty"),
LocalizedDescription("DescSomeProperty")]
public double SomeProperty
{
get { return _someProperty; }
set
{
_someProperty = value;
RaisePropertyChanged("SomeProperty");
}
}
where LocalizedDisplayName class is:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]
sealed class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
static string Localize(string key)
{
string resourceValue = Application.Current.Resources[key].ToString();
try
{
return resourceValue;
}
catch (Exception)
{
return key;
}
}
public LocalizedDisplayNameAttribute(string key)
: base(Localize(key))
{
}
}
It's loading localized properties, but when I change a language on runtime, properties in PropertyGrid are not localized.
On changing language I have such line:
PropertiesUserControl.Refresh();
But properties are not refreshed. When I had a look at ItemsSource in debug mode I found out that Accessors of each PropertyDescriptorDataAccessor are not refreshed and have old localized values. How can I refresh them?
Thank you.