Wpf 将项目位置更改为其他PC时未找到资源

Wpf 将项目位置更改为其他PC时未找到资源,wpf,resources,Wpf,Resources,我对WPF非常陌生。当将WPF项目从一台PC移动到另一台PC时,我发现找不到资源: <Window x:Class="BillingPad.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local ="clr-namespace:Bill

我对WPF非常陌生。当将WPF项目从一台PC移动到另一台PC时,我发现找不到资源:

<Window x:Class="BillingPad.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local ="clr-namespace:BillingPad"
    Title="MainWindow" Height="750" Width="810">

<Window.Resources>

        <Style TargetType="{x:Type Button}" x:Key="ButtonPref">
        <Setter Property="FontSize" Value="48" />
        <Setter Property="Background" Value="Green"/>
        <Setter Property="Foreground" Value="White" />
    </Style>

    <Style x:Key="myStyle" TargetType="Button">
        <Setter Property="Background" Value="Orange" />
        <Setter Property="FontStyle" Value="Italic" />
        <Setter Property="Padding" Value="8,4" />
        <Setter Property="Margin" Value="4" />
    </Style>

</Window.Resources>
......
这将引发以下异常:

<ExceptionString > System.Windows.ResourceReferenceKeyNotFoundException:
Resource 'ButtonPref' not found
System.Windows.ResourceReferenceKeyNotFoundException:
找不到资源“ButtonPref”
我不知道为什么它没有到达资源,因为它保存在范围内的MainWindow.xaml中。。。我不知道配置中缺少了什么或应该更改什么


谢谢

'Button Pref'
看起来空间太大了。请执行“在文件中查找”以找出您引用此内容的位置。很抱歉,在此处写入此内容是我的错误。在程序中写得很好。什么事件包含C#代码?或者更确切地说:C#代码中的
指的是什么?嗨,Erno,谢谢你的时间,它已经解决了,没有改变任何东西。。。我不知道是什么把它弄坏了。“this”指的是MainWindow类,因为这段代码正在其中编写。无论如何,谢谢你。
<ExceptionString > System.Windows.ResourceReferenceKeyNotFoundException:
Resource 'ButtonPref' not found