2

I need to subscribe to an hypothetical event that should be triggered whenever the user changes date, time, or number formats in Clock and Region settings. Below is the picture of how this settings window look in Windows 10 (I suppose that in older Win versions is pretty much the same stuff):

enter image description here

I have to achieve this in order to call ClearCachedData method on my CurrentCulture.

What I have tried is to subscribe to UserPreferenceChanged event following the solution in this question. Nevertheless the event never fires...

I am using WPF although I believe this should not be relevant, although I mention it in case it is...

Further details

My application has a data grid with numeric value editors (I am using Devexpress's controls although this is may be not relevant), so, suppose I have this cell holding a value of 1.5, this will be like so due to the fact that I have set my numeric formats to an English (US) culture. Now, I go to these settings (while having my app running), and change my numeric formats to German(Germany). Then I want to update the displayed value to 1,5. This feature is already supported on Devexpress's controls and WPF in general, I just need to call ClearCachedData and update my layout.

An already existing application that I know for sure does this is Excel (I am sure there must be a lot more), try yourself to set a float value (1.5 e.g.), and with the window opened go to change your numeric formats with a Germany region: the cell updates its displayed value to 1,6.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
taquion
  • 2,667
  • 2
  • 18
  • 29
  • Can you show how/where the handler is setup? Have you tried to the WndProc way, *intercepting* a `WM_SETTINGCHANGE` with `lParam` set to `intl` or `Environment`? A sample method to setup a WndProc handler in WPF is here: [Detect system theme change in WPF](https://stackoverflow.com/a/6360771/7444103) – Jimi Dec 17 '18 at 18:51
  • @Jimi, I basically put `SystemEvents.UserPreferenceChanged += (sender, args) => Console.WriteLine("it works");` in my MainWindow constructor. I have not tried the WndProc approach, but I will. I will let you know if it works or does not. Thanks – taquion Dec 17 '18 at 19:10
  • Allright. Those events are sent to the Top Level Window, just to remember it. – Jimi Dec 17 '18 at 19:11

0 Answers0