我正在制作一個游戲引擎,我正在撰寫一個新的 UI,它給出了以下錯誤“錯誤 XDG0062 'StaticResourceExtension' 對 Setter.Value 無效。唯一支持的 MarkupExtension 型別是 DynamicResourceExtension 和 BindingBase 或派生型別。”
這是自上次作業構建以來添加的唯一代碼
控制模板.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}"到我的主視窗的視窗部分
任何幫助將不勝感激我不知道問題是什么,我發現代碼有任何問題
uj5u.com熱心網友回復:
我忘記了 xaml 有自上而下的代碼流,而我的 App.xalm 檔案有
<ResourceDictionary Source="pack://application:,,,/Dictionaries/ControlTemplates.xaml"/>
在之上
<ResourceDictionary Source="pack://application:,,,/Dictionaries/EditorColors.xaml"/>但它必須是相反的
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/526012.html
標籤:。网wpfxml
