XAML property context set more than once

0

Jestem nowy w XAML-u. Mam tu błąd "The property Context set more than once". Czy ktoś mógłby mi wytłumaczyć dokładnie gdzie robię błąd i na czym on polega?

<Window x:Class="WpfApplication6.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:WpfApplication6"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <ResourceDictionary>
        <Color x:Key="1" A="255" R="255" G="255" B="255"/>
        <Color x:Key="2" A="0" R="0" G="0" B="0"/>
    </ResourceDictionary>
    <Grid>
        <Button Content="tekst" Background="1"/>
    </Grid>
</Window>
1

ResourceDictionary powinien być w znaczniku Window.Resources. Atrybut Background nie przyjmuje wartości numerycznych w sensie nie powinno być tam "1". Tak to wygląda ok.

<Window x:Class="WpfApplication6.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:WpfApplication6"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
   <Window.Resources>
      <ResourceDictionary>
         <Color x:Key="1" A="245" R="105" G="25" B="255" />
         <Color x:Key="2" A="0" R="0" G="0" B="0" />
         <SolidColorBrush
            x:Key="ButtonBackground"
            Color="{StaticResource 1}" />
      </ResourceDictionary>
   </Window.Resources>
   <Grid>
      <Button Content="tekst" Background="{StaticResource ButtonBackground}" />
   </Grid>
</Window>

1 użytkowników online, w tym zalogowanych: 0, gości: 1