Skip to content

A binding error occurs when using DialogHost in version 5.2.1 #3834

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

Open
darkraise opened this issue Apr 21, 2025 · 2 comments
Open

A binding error occurs when using DialogHost in version 5.2.1 #3834

darkraise opened this issue Apr 21, 2025 · 2 comments
Labels
bug evaluation required Items is pending review or evaluation by the team

Comments

@darkraise
Copy link

Bug explanation

Bug detail

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:(no path); DataItem=null; target element is 'VisualBrush' (HashCode=25747420); target property is 'Visual' (type 'Visual')

Environment

.NET MaterialDesign
Version 8.0 5.2.1

App.xaml

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

MainWindow.xaml

 <Window
    x:Class="MDTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:MDTest"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="800"
    Height="450"
    Style="{StaticResource MaterialDesignWindow}"
    mc:Ignorable="d">
    <materialDesign:DialogHost>
        <Grid />
    </materialDesign:DialogHost>
</Window>

Other details

Similar to bug #3228 happened in version 4.9.0

Version

5.2.1

@darkraise darkraise added bug evaluation required Items is pending review or evaluation by the team labels Apr 21, 2025
@corvinsz
Copy link
Member

I think this is due to the static reference to the converter, which was introduced in #3732:

<MultiBinding Converter="{x:Static converters:FirstNonNullConverter.Instance}">

@darkraise
Copy link
Author

Confirm that changing to StaticResource can solve the issue:

<converters:FirstNonNullConverter x:Key="FirstNonNullConverter" />

<!-- deducted -->

<MultiBinding Converter="{StaticResource FirstNonNullConverter}">
    <Binding ElementName="ContentCoverBorder" />
    <Binding Source="{x:Static DependencyProperty.UnsetValue}" />
</MultiBinding>

<!-- deducted -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team
Projects
None yet
Development

No branches or pull requests

2 participants