我正在制作一个游戏引擎,我正在编写一个新的UI,它给出了以下错误:“错误XDG0062 'StaticResourceExtension‘对Setter.Value无效。唯一受支持的MarkupExtension类型是DynamicResourceExtension和BindingBase或派生类型。”
以下是自上次工作构建以来添加的唯一代码
ControlTemplate.xaml
<ResourceDictionary x:Class="Pico_Editor.Dictionaries.ControlTemplates"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Pico_Editor.Dictionaries">
<Style TargetType="{x:Type TextBox}" x:Key="TextBoxStyle">
<!-- TODO: define the look of textbox here -->
</Style>
<Style TargetType="{x:Type TextBox}" x:Key="{x:Type TextBox}" BasedOn="{StaticResource TextBoxStyle}">
<EventSetter Event="KeyDown" Handler="OnTextBox_KeyDown"/>
</Style>
<Style x:Key="PicoWindowStyle" TargetType="{x:Type Window}">
<Setter Property="BorderBrush" Value="{StaticResource Editor.Selected.BackgroundBrush}"/>
<Setter Property="Background" Value="{StaticResource Editor.Window.GrayBrush1}"/>
</Style>
</ResourceDictionary>EditorColors.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Pico_Editor.Dictionaries">
<!-- Editor Colors -->
<Color x:Key="Editor.Window.GrayColor1"> #ff1f1f1f</Color>
<Color x:Key="Editor.Window.GrayColor2"> #ff262626</Color>
<Color x:Key="Editor.Window.GrayColor3"> #ff313131</Color>
<Color x:Key="Editor.Window.GrayColor4"> #ff404040</Color>
<Color x:Key="Editor.Window.GrayColor5"> #ff535353</Color>
<Color x:Key="Editor.Window.GrayColor6"> #ff6a6a6a</Color>
<Color x:Key="Editor.Disabled.FontColor"> #ff868686</Color>
<Color x:Key="Editor.FontColor"> #ffdddddd</Color>
<Color x:Key="Editor.RedColor"> #ffff5a6a</Color>
<Color x:Key="Editor.GreenColor"> #ff90ee90</Color>
<Color x:Key="Editor.BlueColor"> #ff80deff</Color>
<Color x:Key="Editor.OrangeColor"> #ffffd067</Color>
<Color x:Key="Editor.Selected.BackgroundColor"> #ff3c67b6</Color>
<!-- Editor Brushes -->
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor1}" x:Key="Editor.Window.GrayBrush1"/>
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor2}" x:Key="Editor.Window.GrayBrush2"/>
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor3}" x:Key="Editor.Window.GrayBrush3"/>
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor4}" x:Key="Editor.Window.GrayBrush4"/>
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor5}" x:Key="Editor.Window.GrayBrush5"/>
<SolidColorBrush Color="{StaticResource Editor.Window.GrayColor6}" x:Key="Editor.Window.GrayBrush6"/>
<SolidColorBrush Color="{StaticResource Editor.Disabled.FontColor}" x:Key="Editor.Disabled.FontBrush"/>
<SolidColorBrush Color="{StaticResource Editor.FontColor}" x:Key="Editor.FontBrush"/>
<SolidColorBrush Color="{StaticResource Editor.RedColor}" x:Key="Editor.RedBrush"/>
<SolidColorBrush Color="{StaticResource Editor.GreenColor}" x:Key="Editor.GreenBrush"/>
<SolidColorBrush Color="{StaticResource Editor.BlueColor}" x:Key="Editor.BlueBrush"/>
<SolidColorBrush Color="{StaticResource Editor.OrangeColor}" x:Key="Editor.OrangeBrush"/>
<SolidColorBrush Color="{StaticResource Editor.Selected.BackgroundColor}" x:Key="Editor.Selected.BackgroundBrush"/>
</ResourceDictionary>我还将Style="{StaticResource PicoWindowStyle}"添加到主窗口的窗口部分
任何帮助都将不胜感激,我不知道问题出在哪里,我发现代码有什么问题。
发布于 2022-10-30 03:36:04
我忘了xaml有自顶向下的代码流,我的App.xalm文件有
<ResourceDictionary Source="pack://application:,,,/Dictionaries/ControlTemplates.xaml"/>
在……顶端
<ResourceDictionary Source="pack://application:,,,/Dictionaries/EditorColors.xaml"/>但是它必须是相反的
https://stackoverflow.com/questions/74250024
复制相似问题