添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

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

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>

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