0

I have issue with Visual Studio 2022. I am running a WPF solution which is using .netframework 4.8. In this solution I have 2 projects Startup projects - the entry point of application and Views project - where Resource Dictionaries and App.xaml is located. The problem that I got errors "The resource could not be resolved" when try use ResourceDictionary items as static resource in control (like styles or fonts).

It's my App.xaml:

<Application x:Class="Views.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="OnStartup">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles/Colors.xaml"/>
                <ResourceDictionary Source="Styles/Fonts.xaml"/>
                <ResourceDictionary Source="Styles/Global.xaml"/>
                <ResourceDictionary Source="Styles/Windows.xaml"/>
                <ResourceDictionary Source="Styles/Buttons.xaml"/>
                <ResourceDictionary Source="Styles/Storyboards.xaml"/>
                <ResourceDictionary Source="Styles/ScrollBar.xaml"/>
                <ResourceDictionary Source="Styles/Images.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

It's my Fonts.xaml:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <FontFamily x:Key="MulishRegular">pack://application:,,,/Views;component/Resources/Fonts/Mulish-Regular.ttf#Mulish</FontFamily>
    <FontFamily x:Key="MulishLight">pack://application:,,,/Views;component/Resources/Fonts/Mulish-Light.ttf#Mulish Light</FontFamily>
    <FontFamily x:Key="MulishMedium">pack://application:,,,/Views;component/Resources/Fonts/Mulish-Medium.ttf#Mulish Medium</FontFamily>
    <FontFamily x:Key="MulishBold">pack://application:,,,/Views;component/Resources/Fonts/Mulish-Bold.ttf#Mulish Bold</FontFamily>
</ResourceDictionary>

It's the error that I have: issue

I have tried to download project again and clear .vs folder - these actions weren't helpful

EDITED:

My solution was not to keep this files in separate project and move them to root.

0 Answers0