Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization of ColorGallery #279

Closed
Pendergast4Ever opened this issue Feb 29, 2016 · 2 comments
Closed

Localization of ColorGallery #279

Pendergast4Ever opened this issue Feb 29, 2016 · 2 comments
Assignees
Milestone

Comments

@Pendergast4Ever
Copy link

Is there a way to modify the headers in the ColorGallery, e.g. "More Colors...", "No Color"?

@batzen
Copy link
Member

batzen commented Feb 29, 2016

Just had a look and it's hard coded...

Will fix it in a future version.

As a workaround for you right now the only way would be to search for PART_NoColor, PART_MoreColors etc. after the template was applied and replace the header values.

@batzen batzen added this to the 4.1.0 milestone Feb 29, 2016
@batzen batzen self-assigned this Feb 29, 2016
@Pendergast4Ever
Copy link
Author

Thanks,

I derived ColorGallery class as a workaround.
Maybe some parts of it are useful for you.

[TemplatePart(Name = "PART_MoreColors", Type = typeof(MenuItem))]
[TemplatePart(Name = "PART_NoColor", Type = typeof(MenuItem))]
[TemplatePart(Name = "PART_AutomaticColor", Type = typeof(MenuItem))]
public class ColorGallery : Fluent.ColorGallery
{
    public static readonly DependencyProperty MoreColorsHeaderProperty = DependencyProperty.Register(nameof(MoreColorsHeader), typeof(string), typeof(ColorGallery), new PropertyMetadata("More Colors..."));
    public static readonly DependencyProperty NoColorHeaderProperty = DependencyProperty.Register(nameof(NoColorHeader), typeof(string), typeof(ColorGallery), new PropertyMetadata("No Color"));
    public static readonly DependencyProperty AutomaticColorHeaderProperty = DependencyProperty.Register(nameof(AutomaticColorHeader), typeof(string), typeof(ColorGallery), new PropertyMetadata("Automatic"));

    public string MoreColorsHeader
    {
        get { return (string)GetValue(MoreColorsHeaderProperty); }
        set { SetValue(MoreColorsHeaderProperty, value); }
    }

    public string NoColorHeader
    {
        get { return (string)GetValue(NoColorHeaderProperty); }
        set { SetValue(NoColorHeaderProperty, value); }
    }

    public string AutomaticColorHeader
    {
        get { return (string)GetValue(AutomaticColorHeaderProperty); }
        set { SetValue(AutomaticColorHeaderProperty, value); }
    }

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        (GetTemplateChild("PART_MoreColors") as MenuItem)?.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(nameof(MoreColorsHeader)) { Source = this });
        (GetTemplateChild("PART_NoColor") as MenuItem)?.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(nameof(NoColorHeader)) { Source = this });
        (GetTemplateChild("PART_AutomaticColor") as MenuItem)?.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(nameof(AutomaticColorHeader)) { Source = this });
    }
}

@batzen batzen modified the milestones: 5.0.0, 4.1.0 Mar 25, 2016
@batzen batzen closed this as completed in cfe9c47 Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants