Рендеринг wpf несовместим при использовании с Material Design - PullRequest
1 голос
/ 10 июля 2020

У меня следующий XAML в моем элементе управления WPF:

App.Xaml

<Application x:Class="MyWPFApp"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:miscellaneous="clr-namespace:MyWPFApp.Miscellaneous"
         Startup="OnAppStart">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <materialDesign:CustomColorTheme BaseTheme="Light" PrimaryColor="#FF0080FF" SecondaryColor="White" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.Flipper.xaml" />
            <ResourceDictionary Source="Converters/Converters.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Это отображает текстовое поле без ошибки проверки ниже, когда я запускаю приложение и введите что-нибудь в текстовое поле:

XAML 1

<Grid>
    <TextBox 
        Style="{StaticResource MaterialDesignFloatingHintTextBox}"
        VerticalAlignment="Center"
        md:TextFieldAssist.HasClearButton="True"
        md:HintAssist.Hint="Email Address"
        md:HintAssist.HelperText="{Binding ErrorContent}">
        <TextBox.Text>
            <Binding
                UpdateSourceTrigger="PropertyChanged"
                ValidatesOnNotifyDataErrors="True">
                <Binding.Path>Email</Binding.Path>
            </Binding>
        </TextBox.Text>
    </TextBox>
</Grid>

TextBox with no error text below

But when I changed the XAML as follows (Grid enclosed in a MaterialDesign.DialogHost element):

XAML 2


    
         Эл. адрес    

Рендеринг - именно то, что я ожидал:

Текстовое поле с ошибкой под ним

Мой вопрос: не должно быть рендеринга, как на рисунке. 2 с XAML 1?

1 Ответ

0 голосов
/ 10 июля 2020

Да, при условии, что где-то над Grid в дереве элементов есть AdornerDecorator.

Помещение вашего образца разметки в Window по умолчанию работает нормально, т.е. сообщение об ошибке отображается должным образом.

Это все, что есть в App.xaml:

<Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <materialDesign:BundledTheme BaseTheme="Dark" PrimaryColor="DeepPurple" SecondaryColor="Lime" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Использование MaterialDesignThemes 3.1.3.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...