Mahapps.metro: Flyout's header not binding to XmlProvider

Created on 10 Jan 2018  路  8Comments  路  Source: MahApps/MahApps.Metro

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

screenshot_1
and result:

image

Bug

All 8 comments

@Pekshev What version of MahApps do you use?

1.5.0.23

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

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

@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)

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

@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).

https://github.com/MahApps/MahApps.Metro/blob/1f052fd898d1ba7c692b78913525863ff096c69f/src/MahApps.Metro/MahApps.Metro.Shared/Converters/ToUpperConverter.cs#L26-L27

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}}" />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

punker76 picture punker76  路  4Comments

barryBithead picture barryBithead  路  5Comments

robertmuehsig picture robertmuehsig  路  3Comments

Coder-Bryan picture Coder-Bryan  路  3Comments

somil55 picture somil55  路  3Comments