-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsgood first issueGood for newcomersGood for newcomersproposal/opent/a11yRelates to accessibilityRelates to accessibility
Milestone
Description
Description
This proposal was originally done for Forms.
This new functionality would add the ConverterCulture property for bindings, which allows the consumer to override the locale for a binding. This functionality is also available in WPF.
Public API Changes
Added properties:
public class Binding
{
// Default value would be `CurrentCulture` ideally or go to en-US.
// The latter is what WPF does, although I'm not sure why, `CurrentCulture` makes more sense in my mind
[System.ComponentModel.TypeConverter(typeof(CultureInfoIetfLanguageTagConverter))]
public System.Globalization.CultureInfo ConverterCulture { get; set; }
// Add an additional constructor to take the `ConverterCulture` parameter or create an overload for it
// Existing Binding code here
}I think we need to add our own type converter class because the one in WPF/WinUI lives in System.Windows which won't be ideal?
// TypeConverter to make sure we can convert values like en-US and nl-NL
// to a `CultureInfo` object through XAML.
// E.g.: <Label Text="{Binding MyText, ConverterCulture='nl-NL'} />"
public class CultureInfoIetfLanguageTagConverter
{
// Code to transform string into `CultureInfo`
}Intended Use-Case
I don't have a concrete example in mind. The proposal on the Forms repo has been upvoted a couple of times, I guess it can be useful in multi-language, multi-locale scenarios where you want to override something.
Cfun1, sjordanGSS, holecekp, 7702244, LeDahu22 and 1 more
Metadata
Metadata
Assignees
Labels
area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviorsgood first issueGood for newcomersGood for newcomersproposal/opent/a11yRelates to accessibilityRelates to accessibility