C# 类型为'的首次机会例外;System.Windows.Markup.XamlParseException';是否在PresentationFramework.dll中发生?

C# 类型为'的首次机会例外;System.Windows.Markup.XamlParseException';是否在PresentationFramework.dll中发生?,c#,wpf,xaml,xamlparseexception,C#,Wpf,Xaml,Xamlparseexception,嗨,伙计们,我在下面的代码中遇到了一个异常,这段代码运行得很好,但我不明白它现在发生了什么: 例外情况是: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: Provide value on 'System.Windows.StaticResourceExtension'

嗨,伙计们,我在下面的代码中遇到了一个异常,这段代码运行得很好,但我不明白它现在发生了什么: 例外情况是:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Provide value on 'System.Windows.StaticResourceExtension' threw an exception.



<UserControl x:Class="AFIC.View.WirelessConfigurationView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:res="clr-namespace:AFIC.Resources"
                 xmlns:view="clr-namespace:AFIC.View"
                 xmlns:viewmodel="clr-namespace:AFIC.ViewModel"
                >
        <UserControl.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Height"               Value="30"/>
            <Setter Property="FontFamily"           Value="Arial"/>
            <Setter Property="FontSize"             Value="13"/>
            <Setter Property="FontWeight"           Value="Bold"/>
            <Setter Property="Foreground"           Value="Black"/>

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Background="Transparent">

                            <ContentPresenter
                x:Name="contentPresenter"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                Content="{TemplateBinding Content}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="400"  />
        </Grid.RowDefinitions>

        <ScrollViewer Grid.Row="1" Margin="0,10">
            <StackPanel Height="550"   Orientation="Vertical" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>

                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="170"/>
                        <ColumnDefinition Width="200"/>
                        <ColumnDefinition Width="65"/>
                        <ColumnDefinition Width="205"/>

                    </Grid.ColumnDefinitions>

                    <Label
              Grid.Row="0"
              Grid.ColumnSpan="1"
              HorizontalAlignment="Left"
              Content="IP Configuration:"
              Foreground="Black"
              FontWeight="ExtraBold"
              FontSize="14"
              Opacity="0.8"  
            />

                    <Label
             Grid.Row="1"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Wireless IP Address"
             Foreground="Black"
             Opacity="0.8"  
             />
                    <Grid
                Grid.Column="1" 
                Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="40"/>
                            <ColumnDefinition Width="40"/>
                            <ColumnDefinition Width="40"/>
                            <ColumnDefinition Width="40"/>
                        </Grid.ColumnDefinitions>
                        <TextBox
            Grid.Row="1"
            Grid.Column="0"
            VerticalAlignment="Center"
            MaxLength="3" 
            Width="30" 
            Foreground="Black"
            Opacity="0.8"
            Text="{Binding WirelessIP1,UpdateSourceTrigger=PropertyChanged}"
           />
                        <TextBox
            Grid.Row="1"
            Grid.Column="1"
            VerticalAlignment="Center"
            MaxLength="3" 
            Width="30" 
            Foreground="Black"
            Opacity="0.8"
            Text="{Binding WirelessIP2,UpdateSourceTrigger=PropertyChanged}"
           />
                        <TextBox
            Grid.Row="1"
            Grid.Column="2"
            VerticalAlignment="Center"
            MaxLength="3" 
            Width="30" 
            Foreground="Black"
            Opacity="0.8"
            Text="{Binding WirelessIP3,UpdateSourceTrigger=PropertyChanged}"
           />
                        <TextBox
            Grid.Row="1"
            Grid.Column="4"
            VerticalAlignment="Center"
            MaxLength="3" 
            Width="30" 
            Foreground="Black"
            Opacity="0.8"
            Text="{Binding WirelessIP4,UpdateSourceTrigger=PropertyChanged}"
           />
                    </Grid>

                    <Label
             Grid.Row="2"
             Grid.ColumnSpan="1"
             HorizontalAlignment="Left"
             Content="AP Group Configuration"
             Foreground="Black"
             FontWeight="ExtraBold"
             FontSize="14"
             Opacity="0.8"  
             />

                    <Label
             Grid.Row="3"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Group ID"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

                    <TextBox
            Grid.Row="3"
            Grid.Column="1"
            VerticalAlignment="Center"
            Margin="0,0,0,5"
            Text="{Binding GroupId,UpdateSourceTrigger=PropertyChanged}"
           />

                    <Label
             Grid.Row="3"
             Grid.Column="2"
             VerticalAlignment="Center"
             Content="(1-1024)"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

                    <Label
             Grid.Row="4"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="AP Hardware Type"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <ComboBox
            Grid.Row="4"
            Grid.Column="1"
            ItemsSource="{Binding AvailableHwTypes}" 
            SelectedItem="{Binding SelectedApHardwareType}"
            >
                    </ComboBox>

                    <Button
            Grid.Row="4"
            Grid.Column="2"
            Margin="10,0,0,0"
                        Command=""
            Style="{StaticResource AddHwType}">
                        Add
                    </Button>
                    <Button
            Grid.Row="6"
            Grid.Column="3"
            Margin="10,0,0,0"
            Style="{StaticResource AppButtons}"
            Command="{Binding ConfigWireless}">
                        Configuration
                    </Button>

                    <TextBox 
            Grid.Row="5"
            Grid.ColumnSpan="3"
            IsReadOnly="True"
            IsEnabled="False"
            Visibility="Hidden"
            Height="10"/>

                    <DataGrid 
                  Grid.Row="6"
                  Grid.ColumnSpan="3"
                  Height="100"
                  AutoGenerateColumns="False"
                  ItemsSource="{Binding wirelessconfiguration}"
                  SelectedValue="{Binding SelectedWireless}"
                  Name="dg"
                  >
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="100"  Header="S.No" Binding="{Binding Path=S_No}"/>
                            <DataGridTextColumn Width="100"  Header="Group ID" Binding="{Binding Path=_groupId}"/>
                            <DataGridTextColumn Width="200" Header="AP Hardware Type" Binding="{Binding Path=_apHardwareType}"/>
                        </DataGrid.Columns>
                    </DataGrid>

                    <Label
             Grid.Row="7"
             Grid.Column="0"
             HorizontalAlignment="Left"
             Content="Network Configuration"
             FontWeight="ExtraBold"
             Foreground="Black"
             FontSize="14"
             Opacity="0.8"  
             />

                    <Label
             Grid.Row="8"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="SSID"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <TextBox
            Grid.Row="8"
            Grid.Column="1"
            VerticalAlignment="Center"
            Text="Guest Network"
           />

                    <Label
             Grid.Row="9"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Security"
             Foreground="Black"
             Opacity="0.8"  
             />
                    <ComboBox 
                        Margin="0,5,0,8"
                Grid.Row="9"
                Grid.Column="1"
                ItemsSource="{Binding ACAvailableSecurityTypes}"
                SelectedItem="{Binding ACSelectedSecurityType}"
                >

                    </ComboBox>

                    <view:ACSecurityStaticWEP

                Grid.Row="11"
                Grid.ColumnSpan="3"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Visibility="{Binding IsACStaticWep, Converter={StaticResource BooleanToVisibilityConverter}}"
                />
                    <view:ACSecurityTypeWepIEEE

                Grid.Row="11"
                Grid.ColumnSpan="3"
                HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                Visibility="{Binding IsACWEPIEEE, Converter={StaticResource BooleanToVisibilityConverter}}"
                />
                    <view:ACSecurityTypeWPAUC

                Grid.Row="11"
                Grid.ColumnSpan="3"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                Visibility="{Binding IsACWPAPersonal, Converter={StaticResource BooleanToVisibilityConverter}}"
                />
                    <view:ACSecurityTypEnterprise

                Grid.Row="11"
                Grid.ColumnSpan="3"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Visibility="{Binding IsACWPAEnterprise, Converter={StaticResource BooleanToVisibilityConverter}}"
                />
                </Grid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
PresentationFramework.dll中发生了类型为“System.Windows.Markup.XamlParseException”的首次意外异常
其他信息:提供“System.Windows.StaticResourceExtension”上的值引发异常。
添加
配置

有人能告诉我问题出在哪里吗。任何帮助都是非常值得的。

似乎使用的
静态资源之一不存在:

要么:

  • AddHwType
    (按钮样式)
  • AppButtons
    (按钮样式)
  • BooleanToVisibilityConverter
    (转换器)

  • 您可能会在某个地方丢失合并词典,或者在使用它之前忘记添加资源。查看以获取更多信息。

    已解决:我使用了错误的
    静态资源
    我正在编写
    Style=“{StaticResource AddHwType}”
    并且应该是
    Style=“{StaticResource AppButtons}”
    :)