WPF baml serialization bug?

377 Views Asked by At

The following XAML produces XamlParseException in runtime:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <Grid>
    <Grid.Resources>
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary>
            <TextBlock x:Key="{x:Type TextBlock}">
              <Run Text="Aaaa"/>
            </TextBlock>
          </ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
        <sys:String x:Key="aaa"></sys:String>
      </ResourceDictionary>
    </Grid.Resources>
    <Border Child="{StaticResource {x:Type TextBlock}}"/>
  </Grid>
</Window>

XamlParseException: 'Missing key value on 'TextBlock' object.' Line number '10' and line position '20'.

What am I doing wrong?

1

There are 1 best solutions below

2
On

Keys can't be types, they're strings.