Wpf 资源字典中的越界错误

Wpf 资源字典中的越界错误,wpf,styles,Wpf,Styles,我已将共享样式放入应用程序中包含的单个资源字典中。例如,在名为GlobalStyles.xaml的文件中,我有以下内容: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="Base

我已将共享样式放入应用程序中包含的单个资源字典中。例如,在名为
GlobalStyles.xaml的文件中,我有以下内容:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="BaseStyle" TargetType="FrameworkElement">...</Style>
    <Style x:Key="ExtendedStyle" TargetType="FrameworkElement" BasedOn="{StaticResource BaseStyle}">...</Style>
</ResourceDictionary>


这一定是我正在使用的VS2012的一个bug。我搬到VS2010,问题就解决了。我对VS2012 designer有很多问题。它经常挂起,抛出异常,在没有语法错误时抱怨语法错误,而现在是这样。现在我将继续使用VS2010。

在一个示例中进行了尝试,不会引发任何异常。你试过重新启动VS吗?另外,你也可以发布样式的XAML吗?胡乱猜测-可能尝试将app.XAML中的
合并在一起?@sthotakura重新启动VS没有帮助。我也添加了样式。@Viv使用合并词典也没有帮助。GlobalStyles.xaml的生成操作是什么?
<Application.Resources>
    <ResourceDictionary Source="GlobalStyles.xaml" />
</Application.Resources>
    <Style x:Key="BaseStyle" TargetType="FrameworkElement">
    <!-- Background -->
    <Setter Property="Control.Background" Value="{StaticResource White0ColorBrush}"/>
    <!-- Border -->
    <Setter Property="Control.BorderBrush" Value="{StaticResource Green1ColorBrush}"/>
    <Setter Property="Control.BorderThickness" Value="0"/>
    <!-- Font -->
    <Setter Property="Control.FontWeight" Value="Light"/>
    <Setter Property="Control.Foreground" Value="{StaticResource Green0ColorBrush}"/>
    </Style>
<Style x:Key="ExtendedStyle" TargetType="FrameworkElement" BasedOn="{StaticResource BaseStyle}">
    <Setter Property="Control.Background" Value="{StaticResource Green1ColorBrush}"/>
    <Setter Property="Control.Foreground" Value="{StaticResource White0ColorBrush}"/>
</Style>
    <Grid>
      <Border BorderThickness="2" CornerRadius="5" BorderBrush="{StaticResource White0ColorBrush}" Style="{StaticResource ExtendedBaseStyle}">
        <Grid>
           <TextBox x:Name="SearchField" Height="20" BorderThickness="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" />
        </Grid>
      </Border>
    </Grid>