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

Flyout's header not binding to XmlProvider #3143

Closed
Pekshev opened this Issue Jan 10, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@Pekshev

Pekshev commented Jan 10, 2018

I'm use XmlProvider for localization of my app. All good but flyout's header not binding:

screenshot_1
and result:

image

@punker76

This comment has been minimized.

Member

punker76 commented Jan 10, 2018

@Pekshev What version of MahApps do you use?

@Pekshev

This comment has been minimized.

Pekshev commented Jan 10, 2018

1.5.0.23

@Pekshev

This comment has been minimized.

Pekshev commented Jan 10, 2018

I found the solution - I set the header in the code when the window is loaded. But I would like to do this in the xaml

@punker76

This comment has been minimized.

Member

punker76 commented Jan 10, 2018

@Pekshev Can you create a short sample on GitHub? With one Flyout and such a XmlProvider?

@Pekshev

This comment has been minimized.

Pekshev commented Jan 11, 2018

@punker76 punker76 self-assigned this Jan 11, 2018

@punker76 punker76 added the Bug label Jan 11, 2018

@punker76 punker76 added this to the 1.6.0 milestone Jan 11, 2018

@punker76

This comment has been minimized.

Member

punker76 commented Jan 11, 2018

@Pekshev Thank you for this sample! 👏 It helps me to find the bug :-D

image

This fix will be available in 1.6.0 (and next pre-release)

@Pekshev

This comment has been minimized.

Pekshev commented Jan 11, 2018

I will not create a new issue.
There is also a bug - when binding is not set the upper case for text in many controls. The simplest example is the groupBox.

screenshot_9

I updated the demo project

@punker76

This comment has been minimized.

Member

punker76 commented Jan 11, 2018

@Pekshev the same happens at the Buttons (these captions should be also upper cased). The problem here is, that the ToUpper (and ToLower) converters gets a XmlNode and not a string through the binding (Header or Content).

var val = value as string;
return val != null ? val.ToUpper() : value;

You can create a simple converter to solve this

    public class XmlNodeToTextConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var xmlNode = value as XmlNode;
            if (xmlNode != null)
            {
                value = xmlNode.InnerText;
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }

Usage

<GroupBox Header="{Binding Source={StaticResource Lang}, XPath=t6, Converter={StaticResource XmlNodeToTextConverter}}" />

punker76 added a commit that referenced this issue Jan 12, 2018

Fix #3143 Flyout's header not binding to XmlProvider
  Changing the inner TextBlock to a ContentControl solves this.

punker76 added a commit that referenced this issue Jan 12, 2018

Merge pull request #3145 from MahApps/feature/GH-3143_change_Flyouts_…
…inner_header_presenter

Fix for #3143 Flyout's header not binding to XmlProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment