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

System.Windows.Markup.XamlParseException #7894

Closed
BlyZeDev opened this issue Jun 2, 2023 · 2 comments
Closed

System.Windows.Markup.XamlParseException #7894

BlyZeDev opened this issue Jun 2, 2023 · 2 comments

Comments

@BlyZeDev
Copy link

BlyZeDev commented Jun 2, 2023

Description

<tools:FlexibleWindow x:Class="MyApp.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:tools="clr-namespace:WpfTools;assembly=WpfTools"
                      Style="{StaticResource WindowStyle}">
</tools:FlexibleWindow>
<Application x:Class="MyApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:tools="clr-namespace:WpfTools;assembly=WpfTools">
    <Application.Resources>
        <Style x:Key="WindowStyle" TargetType="{x:Type tools:FlexibleWindow}">
            <Setter Property="AspectRatio" Value="16,9"/>
            <Setter Property="RelativeMinWindowSize" Value="0.45"/>
            <Setter Property="RelativeWindowSize" Value="0.65"/>
            <Setter Property="Title" Value="Linematrix"/>
            <Setter Property="Icon" Value="Icon.ico"/>
        </Style>
    </Application.Resources>
</Application>

When I start my app it crashes instantly with an XamlParseException.

System.Windows.Markup.XamlParseException: "Zeilennummer"4" und Zeilenposition "23" von "Die Angabe eines Werts für "System.Windows.StaticResourceExtension" führte zu einer Ausnahme."."

Inner Exception:
Exception: Die Ressource mit dem Namen "WindowStyle" kann nicht gefunden werden. Bei Ressourcennamen wird die Groß- und Kleinschreibung berücksichtigt.

Reproduction Steps

Good question how to reproduce because in my other project it works perfectly fine.

Expected behavior

That it loads the style.

Actual behavior

It crashes with an exception.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

.NET 7
Windows 11
64 Bit

Other information

No response

@ThomasGoulet73
Copy link
Contributor

ThomasGoulet73 commented Jun 2, 2023

This is probably the same bug as #4457.

@BlyZeYT: Could you try this workaround by changing the XAML for your Application so it looks like this:

<Application x:Class="MyApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:tools="clr-namespace:WpfTools;assembly=WpfTools">
    <Application.Resources>
        <Style x:Key="WindowStyle" TargetType="{x:Type tools:FlexibleWindow}">
            <Setter Property="AspectRatio" Value="16,9"/>
            <Setter Property="RelativeMinWindowSize" Value="0.45"/>
            <Setter Property="RelativeWindowSize" Value="0.65"/>
            <Setter Property="Title" Value="Linematrix"/>
            <Setter Property="Icon" Value="Icon.ico"/>
        </Style>
        <!-- This is the important part -->
        <Style x:Key="Workaround" />
    </Application.Resources>
</Application>

@BlyZeDev
Copy link
Author

BlyZeDev commented Jun 2, 2023

This is probably the same bug as #4457.

@BlyZeYT: Could you try this workaround by changing the XAML for your Application so it looks like this:

<Application x:Class="MyApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:tools="clr-namespace:WpfTools;assembly=WpfTools">
    <Application.Resources>
        <Style x:Key="WindowStyle" TargetType="{x:Type tools:FlexibleWindow}">
            <Setter Property="AspectRatio" Value="16,9"/>
            <Setter Property="RelativeMinWindowSize" Value="0.45"/>
            <Setter Property="RelativeWindowSize" Value="0.65"/>
            <Setter Property="Title" Value="Linematrix"/>
            <Setter Property="Icon" Value="Icon.ico"/>
        </Style>
        <!-- This is the important part -->
        <Style x:Key="Workaround" />
    </Application.Resources>
</Application>

Now it works thanks :)

@BlyZeDev BlyZeDev closed this as completed Jun 2, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants