Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';System.Windows.Markup.XamlParseException';发生在System.Windows.ni.dll中_C#_Xaml_Windows Phone 8_Wptoolkit - Fatal编程技术网

C# ';System.Windows.Markup.XamlParseException';发生在System.Windows.ni.dll中

C# ';System.Windows.Markup.XamlParseException';发生在System.Windows.ni.dll中,c#,xaml,windows-phone-8,wptoolkit,C#,Xaml,Windows Phone 8,Wptoolkit,我在Windows Phone应用程序中遇到此错误: 类型的第一次机会例外 中出现“System.Windows.Markup.XamlParseException” System.Windows.ni.dll 只有在我的应用程序中安装并添加了对的引用后,才会发生这种情况,如下所示: xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

我在Windows Phone应用程序中遇到此错误:

类型的第一次机会例外 中出现“System.Windows.Markup.XamlParseException” System.Windows.ni.dll

只有在我的应用程序中安装并添加了对的引用后,才会发生这种情况,如下所示:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
public MainPage()
{
    InitializeComponent();
}
我在下一行得到了错误

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
public MainPage()
{
    InitializeComponent();
}
问题可能是什么?可能的解决方法是什么


ApplicationPage

XAML

<ListBox x:Name="ContactResultsData" Tap="ContactResults_Tap_1" ItemsSource="{Binding}" Height="600" Loaded="ContactResultsData_Loaded_1" Margin="10,0">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" Margin="0, 20, 0, 0">
                <Border BorderThickness="2" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="5, 0, 0, 0">
                    <Image Source="{Binding Converter={StaticResource ContactPictureConverter}}" Width="48" Height="48" Stretch="Fill"  />
                </Border>
                <TextBlock x:Name="ContactResults" Text="{Binding DisplayName, Mode=OneWay}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="10, 0, 0, 0" />
            </StackPanel>
            <toolkit:ContextMenuService.ContextMenu>
                <toolkit:ContextMenu>
                    <toolkit:MenuItem Header="Test">

                    </toolkit:MenuItem>
                </toolkit:ContextMenu>
            </toolkit:ContextMenuService.ContextMenu>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

以下是一个工作证明:

文件-->新建项目-->新建数据绑定应用程序(wp8),下面是代码:

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox x:Name="ContactResultsData" Tap="ContactResults_Tap_1" ItemsSource="{Binding Items}" Height="600" Loaded="ContactResultsData_Loaded_1" Margin="10,0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0, 20, 0, 0">
                                <Border BorderThickness="2" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="5, 0, 0, 0">
                                    <Image Width="48" Height="48" Stretch="Fill" Source="/Assets/Tiles/FlipCycleTileSmall.png"  />
                                </Border>
                                <TextBlock x:Name="ContactResults" Text="{Binding LineOne, Mode=OneWay}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="10, 0, 0, 0" />
                            </StackPanel>
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu>
                                    <toolkit:MenuItem Header="Test">

                                    </toolkit:MenuItem>
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
        </Grid>

你的xaml文件有问题。尝试调试xaml中的问题所在。如何调试
xaml
文件?我只添加了这一行,它是解决方案中的引用。如果不是这样的话,效果很好。事实上这很奇怪。您确定没有安装任何其他工具包吗?因为我可以毫无例外地向您发送10个引用该文件的项目。检查您的XAML closer或为其提供代码(.XAML和.cs)@GeorgeNikolaides是的,我稍后会提供代码:)cheers@GeorgeNikolaides已更新,请查看。感谢您在这方面花费的时间,我使用的是windows 8.1和VS Express for windows phone。win 8.1与此相关吗?我将我的应用程序放在github上,稍后我会在家里发布一个链接给你,我使用win8和VS12 ultimate,在笔记本电脑上使用win8.1和VS12,两者都可以接受我给出的示例。让我来测试一下git codeCheers mate,非常感谢您在这方面花了大量时间,我对wp和c完全是个新手。顺便说一句,问题似乎出在
ContactResults\u Tap_1
方法的签名下。这是错误的。我已经编辑了答案并添加了正确的签名。始终使用visual studio自动创建此类方法/处理程序。还请查看此项-我强烈建议使用它
Microsoft.Phone.Controls.GestureEventArgs
应该是
GestureEventArgs
?那是唯一的事?因为,删除
Microsoft.Phone.Controls
会给我一个错误-->'GestureEventArgs'是'System.Windows.Input.GestureEventArgs'和'Microsoft.Phone.Controls.GestureEventArgs'之间的不明确引用