DateTime format used in PropertyGrid

Grids for WPF Forum

Posted 13 years ago by Helmut Zörrer
Version: 11.2.0552
Avatar

hi dear support,

(1) i'm driving nuts to get out how i can change the DateTime format used in the PropertyGrid per Default,

i'm in a german environment having an english operating system but want to see

dd.MM.yyyy instead of MM/dd/yyyy per default.

funnily your 'property editors' sample shows DateTime things in dd.MM.yyyy

how can i get this easily ?

do i really have to implement a new PropertyEditor only to specify the default datetime settings used?

(2) in some cases i want DateTime fields to be used only as a Date - is this possible via a attribute (type-converter) or do i need a special PropertyEditor?

 

HINT: i'm doing all things in code and would prefer some attribut-tagging solution (without XAML) because the objects i'm inspecting differ on the same propertygrid. (think of sometimes i'm inspecting a house then an apple - changing attributes for class house and class apple is easy...)

g

 Helmut

[Modified 13 years ago]

Comments (2)

Answer - Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Helmut,

1. The display of the dates is more a function of WPF and .NET, then our PropertyGrid. The PropertyGrid provides an abstraction layer to "properties" and then the means to hook up editors to those properties. But the editors, even the default ones built in, are simply other WPF controls. The default ones happen to use controls like the native WPF TextBox, ComboBox, and CheckBox.

The properties of these controls are then bound to our abstraction layer, and it is usally this binding that would convert a DateTime to a string for display in a TextBox or CombBox. But even our DateTimeEditor in our Editors for WPF will use the current system format to determine how to display.

You can change how your entire application displays dates using a approach such as this one.

2. In those case, you would need a custom TypeConverter (see our Custom TypeConverters QuickStart for a complete example), which you'd associated with your property. The TypeConverter will then be called to convert the DateTime to/from a string.


Actipro Software Support

Posted 13 years ago by Helmut Zörrer
Avatar

THX for the enlightment :-))))

(1) Works like a charme now:

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE");
System.Windows.FrameworkElement.LanguageProperty.OverrideMetadata(typeof(System.Windows.FrameworkElement),
new System.Windows.FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag)));

for those who want to follow ;-)

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.