Cannot find resource dictionary in WPF application

后端 未结 4 1675
长发绾君心
长发绾君心 2021-01-18 03:49

I\'m in the process of building a WPF application and ran into an error when trying to reference a resource dictionary. Inside my WPF application project I have a folder cal

相关标签:
4条回答
  • 2021-01-18 03:52

    Sometimes closing Visual Studio and open it again solves this problem.

    0 讨论(0)
  • 2021-01-18 03:53

    Change the target .net version to an older one in the project properties and then reset to the previous version.

    0 讨论(0)
  • 2021-01-18 04:09

    Make sure that the build action for MetroTheme.xaml is set to Page.

    enter image description here

    0 讨论(0)
  • 2021-01-18 04:16

    I had the same issue, but setting Build Action = Page did not solve for me. Turned out I needed to use the Pack URI Format. So,

    <ResourceDictionary Source="pack://application:,,,/Styles/MetroTheme.xaml"/>
    

    EDIT

    Turns out the above will eliminate build error but still results in runtime error. I needed to include full assembly specification for complete resolution (even though all files are in same assembly):

    <ResourceDictionary Source="pack://application:,,,/WpfApplication10;component/Styles/MetroTheme.xaml"/>
    
    0 讨论(0)
提交回复
热议问题