从背后的代码设置Bing Maps Silverlight控件属性 [英] setting Bing Maps Silverlight Control Property From Code Behind

查看:52
本文介绍了从背后的代码设置Bing Maps Silverlight控件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在加载页面上的控件之前,我需要从代码后面设置CredentialsProvider.我在代码的后面有"ApiKey"依赖项属性,并将其绑定到Bing Maps silverlight控件,但是它不起作用.它在运行时给出错误凭据无效".

I need to set the CredentialsProvider from code behind prior to load the control on page. I have "ApiKey" dependency property in code behind and binding it to Bing Maps silverlight Control but it doesn't work. It gives an error "invalid credentials" at run time.

隐藏代码

public static readonly DependencyProperty ApiKeyProperty = DependencyProperty.Register("ApiKey", typeof(string), typeof(MainPage), new PropertyMetadata(""));
protected string ApiKey
{
    get { return this.GetValue(ApiKeyProperty) as string; }
    set { this.SetValue(ApiKeyProperty, value); }
}

XAML

<m:Map x:Name="map" Grid.Row="1" Grid.ColumnSpan="5" Margin="0" CredentialsProvider="{Binding ElementName=silverlightMap, Path=ApiKey}" 
               Mode="Road" MouseMove="map_MouseMove" MouseLeftButtonUp="map_MouseLeftButtonUp" MouseLeftButtonDown="map_MouseLeftButtonDown"
               ViewChangeEnd="map_ViewChangeEnd"></m:Map>

类名是MainPage,并且是从UserControl继承的.

The class name is MainPage and is being inherited from UserControl.

推荐答案

CredentialsProvider = new ApplicationIdCredentialsProvider("AbcdEfghIjklMNnoP_4rlMTclX8iXiNYUYQnG3GPYoxABCDEmoj3cCBemAAG")

这篇关于从背后的代码设置Bing Maps Silverlight控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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