尝试在OS build 17134上的MapControl中设置DataContext会导致崩溃。 [英] Trying to set DataContext in MapControl on OS build 17134 causes a crash.

查看:56
本文介绍了尝试在OS build 17134上的MapControl中设置DataContext会导致崩溃。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图设置操作系统版本17134上的MapControl的DataContext导致应用程序崩溃,但相同的代码在运行
OS 16299的计算机上正常工作。

设置"DataContext"时=此"对于MapControl,在提供MapServiceToken值之前,我收到异常:

When setting "DataContext=this" for MapControl before providing the MapServiceToken value, I am getting the exception:

消息: 外部组件抛出异常。

Message: External component has thrown an exception.

来源:  Windows

Source: Windows

StackTrace: 

  ;在Windows.UI.Xaml.FrameworkElement.put_DataContext(对象值)

    at App1.MainPage..ctor()

    at App1.App1_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()

    at App1.App1_XamlTypeInfo.XamlUserType.ActivateInstance()

  at Windows.UI.Xaml.FrameworkElement.put_DataContext(Object value)
   at App1.MainPage..ctor()
   at App1.App1_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
   at App1.App1_XamlTypeInfo.XamlUserType.ActivateInstance()

但如果我设置"DataContext = this",则应用程序正常运行提供MapServiceToken值后。

But the application is working fine if I am setting "DataContext=this" after providing the MapServiceToken value.

此问题在OS build 17134中重现。

This issue is reproduced in OS build 17134.

相同的代码在OS build 16299中正常工作。

The same code is working fine in OS build 16299.

这是我的应用程序代码:

This is my application code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace App1
{
    public sealed partial class MainPage : Page
    {
        public string ServiceToken
        {
            get { return (string)GetValue(ServiceTokenProperty); }
            set { SetValue(ServiceTokenProperty, value); }
        }

        public static readonly DependencyProperty ServiceTokenProperty = DependencyProperty.Register(
            "ServiceToken",
            typeof(string),
            typeof(MainPage),
            new PropertyMetadata(string.Empty));

        private string mapKey = "__BINGMAPSPROVIDEDKEY__";
        public MainPage()
        {
            this.InitializeComponent();
            DataContext = this;
            ServiceToken = mapKey;
        }
    }
}

这是同一页面的xaml代码,"MainPage" :

This is the xaml code for the same page, "MainPage" :

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    xmlns:maps="using:Windows.UI.Xaml.Controls.Maps">
    <Grid>
        <maps:MapControl
            MapServiceToken="{Binding ServiceToken}"
            />
    </Grid>
</Page>

为什么这个问题出现在图片中并且有操作系统更新?

Why this issue came in picture with the OS update?

Rohit Garg。

Rohit Garg.

推荐答案

您使用的是Bing地图吗?为Windows UWP应用程序创建的密钥?创建用于Web控件的密钥将不起作用。
Are you using a Bing maps key that was created for use with Windows UWP applications? Keys created for use with the web control will not work.


这篇关于尝试在OS build 17134上的MapControl中设置DataContext会导致崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆