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

Xaml warning: Resource '{x:Type MahApps.Metro.Controls.MetroWindow}' is not found #4457

Closed
kgday opened this issue Jan 8, 2024 · 4 comments
Labels

Comments

@kgday
Copy link

kgday commented Jan 8, 2024

Describe the bug

I am not sure when this warning started to be emitted. But noticed it today. When creating a custom window style and attempting to base it from the MetroWindowStyle, I am getting Resource '{x:Type MahApps.Metro.Controls.MetroWindow}' is not found.

Steps to reproduce

The xaml resources header is 
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
    xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
...
>

The custom style:

    <Style
        x:Key="CustomMetroWindow"
        TargetType="{x:Type controls:MetroWindow}"
        BasedOn="{StaticResource {x:Type controls:MetroWindow}}">
        <Setter Property="ShowTitleBar" Value="True" />
        <Setter Property="Height" Value="600" />
        <Setter Property="Width" Value="1024" />
        <Setter Property="FontFamily" Value="Roboto" />
    </Style>

It is on the BasedOn line that the warning is being emitted.

There should not be a warning emitted for this, I would have thought. I have obviously done something wrong or something has changed.

I get the warning in both rider and visual studio with resharper

Environment

MahApps.Metro version: v2.4.10
Windows build number: Windows 11 Pro, version 21H2, Build 22000.2538
JetBrains Rider: 2023.3.2
Visual Studio: 2022  17.8.0
JetBrains ReSharper 2023.3.2
Target Framework: .Net 8.0
@kgday kgday added the Bug label Jan 8, 2024
@timunie
Copy link
Collaborator

timunie commented Jan 8, 2024

Is it probalby a controls lib that doesn't reference MahApps on it's own?

@kgday
Copy link
Author

kgday commented Jan 12, 2024

This is directly in my wpf application with a main window, not in a controls lib and directly references mahapps.

@timunie
Copy link
Collaborator

timunie commented Jan 12, 2024

ah wait looks like MetroWindow does not support this feature to inherit the style. Check original styles for reference.

@punker76
Copy link
Member

I think this issue is not related to MahApps itself. Yes, it's not nice to see this, but at the end it's a waning and is a designer xaml parsing issue. One suggestion is to put the style in the App.xaml and use it then with DynamicResource.

<mah:MetroWindow x:Class="MetroDemo.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:mah="http://metro.mahapps.com/winfx/xaml/controls"
...
                 Style="{DynamicResource CustomMetroWindow}"
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants