我从事 WPF 项目已经有一段时间了,但现在已经有 2 个月没有碰它了。现在我回来了,我有以下问题:
我使用合并字典来创建皮肤,并在运行时轻松交换它们。但是,每个皮肤在运行时都不会改变。但是,虽然我对此不以为然,但我只是遵循了一堆教程,并且到处使用 DynamicResource,甚至不知道是否应该使用 StaticResource。
结果是,当我尝试使用 Windows XP(我使用七个)将我的应用程序发送给朋友时。Luna 主题被抛出我的应用程序,使设计变得丑陋......据我所知,它来自 DynamicResource。
所以现在,我想更改为StaticResource,我只是尝试用“StaticResource”替换每个“DynamicResource”。它向我抛出了这个异常:
Message = "'La valeur fournie sur 'System.Windows.StaticResourceExtension' a levé une exception.' numéro de ligne '8' et position de ligne '230'."
In english, it means: Message = "'The value given to 'System.Windows.StaticResourceExtension' threw an exception.' line number '8' and position on the line '230'.
然后我放了一个 try/catch 块来更好地了解问题:
{"Impossible de trouver la ressource nommée'styleBackground'. Les noms de ressources respectent la casse."}
用英语:Impossible to find the resource named 'styleBackground'. The resource names are case sensitive.
这是关于一个 TabItem 的。
所以这里有两个问题:我是否通过将 DynamicResource 更改为 StaticResource 来做正确的事情?如果是这样,我需要做什么?
谢谢,
FB。
编辑:程序在这些行的最后一行得到错误:
<Window x:Class="Sc2ReplayMonkey.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:local="clr-namespace:Sc2ReplayMonkey" ResizeMode="CanResize"
Title="Starcraft II Replay Monkey"
Width="991" Icon="Resources\Icons\SC2_Replay_Monkey.png"
WindowStartupLocation="CenterScreen" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="1024" Height="774" Visibility="Visible" Foreground="#00000000" Margin="0">