0

运行程序时出现以下错误:

警告 资源“bellRingersStyle”无法解析。

这出现在最后两行,即{StaticResource bellRingersStyle}.

    <Window x:Class="BellRingers.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Middleshire Bell Ringers Association – Members" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="bellRingerStyle" TargetType="Control">
            <Setter Property="Button.Background" Value="Gray"/>
            <Setter Property="Button.Foreground" Value="Gray"/>
            <Setter Property="Button.FontFamily" Value="Comic Sans MS"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="Blue"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <Button Style="{StaticResource bellRingerStyle}" Panel.ZIndex="1" Content="Button" Height="23" HorizontalAlignment="Left" Margin="400,131,0,0" Name="button1" VerticalAlignment="Top" Width="75" >
            </Button>
        <Button Style="{StaticResource bellRingersStyle}" Panel.ZIndex="1" Content="Button" Height="23" Margin="0,0,0,0" Name="button2" Width="75" />
            <Image Panel.ZIndex="0" Margin="0,0,0,0" Name="image1" >
            <Image.Source>
                <BitmapImage UriSource="bell.gif" />
            </Image.Source>
        </Image>
        <TextBox Style="{StaticResource bellRingersStyle}"  Height="23" HorizontalAlignment="Left" Margin="206,271,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
    </Grid>
</Window>
4

1 回答 1

2

你有一个错字。您将其定义为 bellRingerStyle 但引用 bellRingersStyle。

于 2013-12-08T03:35:19.880 回答