A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll?

CodeSniper picture CodeSniper · Jun 30, 2014 · Viewed 11.4k times · Source

Hi guys i am facing an exception in the following code,this code was working fine but i dont understand what happened to it now: Exception is :

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>

Can anyone tell me where is the problem.Any help would be highly appreciable.

Answer

Bas picture Bas · Jun 30, 2014

It seems that one of the StaticResources used does not exist:

Either:

  1. AddHwType (Button Style)
  2. AppButtons (Button Style)
  3. BooleanToVisibilityConverter (Converter)

You might miss a merged dictionary somewhere or forgot to add a resource before using it. Review the XAML Resources page on MSDN for more info.