誰かがこの問題を解決するのを助けてくれますか、私は必要なキーを正しくコーディングしていると思います。これは、ボタンが1つのみのスタイルアプリケーション辞書テストです。各辞書エントリには関連するキーが必要であり、IDictionaryに追加されたすべてのオブジェクトにはKey属性またはそれに関連付けられた他のタイプのキーが必要です。 Line 13 Position 14、どちらもMainWIndow.xamlです。各辞書エントリには、関連するキーエラーメッセージが必要です
このプロジェクトでは、プログラマが作成したコードはありません。
これはMainWindow.xamlコードです:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary Source="App.xaml" /> This is the offending line
</ResourceDictionary>
</Window.Resources>
<Grid>
<Button Style="{StaticResource algo}" />
</Grid>
そしてこれはApp.xamlコードです:コメントで指摘したように、
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="algo" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Red" />
</Style>
</Application.Resources>
違反行は 'ResourceDictionary.MergedDictionaries'の内部にある必要があります。それ以外の場合は、辞書内のエントリとして扱われます。 [Documentation](https://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary.mergeddictionaries(v = vs.110)。aspx) –