1

In C# WPF, how to get the list of Windows 10 available languages, I need this to load the dropdown list in WPF.

I see this is available in UWP but I don't find one for WPF. https://social.msdn.microsoft.com/Forums/vstudio/en-US/e2954327-fe9e-484e-95bf-e6b1e3f32858/uwp-howto-show-language-list-with-installed-input-languages-at-the-top?forum=wpdevelop

Magesh
  • 49
  • 2
  • 2
    Possible duplicate of [List of all available languages for Windows .NET framework](https://stackoverflow.com/questions/37244656/list-of-all-available-languages-for-windows-net-framework) – Matt.G Jun 20 '19 at 19:20

1 Answers1

1

You can add this NuGet Package Microsoft.Windows.SDK.Contracts so you can access Windows.System.UserProfile.GlobalizationPreferences from WPF.

Then you can call this code from your WPF Application:

var languages = Windows.System.UserProfile.GlobalizationPreferences.Languages.ToList();

It will contain a list of string of languages that are preferred by the user, in order of preference. On my machine, it returns "pt-BR":

Culture

References: https://blogs.windows.com/windowsdeveloper/2019/04/30/calling-windows-10-apis-from-a-desktop-application-just-got-easier/#eAjFgDgbqEcJZIqb.97

Note that it requires default package management format set to PackageReference, and NuGet 4.0 or higher.

You can do it on Visual Studio 2019 using the context menu: Screenshot

Tony
  • 16,527
  • 15
  • 80
  • 134