1
bing地图包含一个名为setview的方法,用于计算地图的右缩放级别。silverlight,C#,为XAML添加额外控件
我自己用MVVM框架构建了一个地图应用程序。我想为我的地图使用setview方法。但是因为我在MVVM中构建了应用程序,所以在视图模型中使用setview并不好,因为viewmodel不知道任何有关map.xaml的内容。 我将XAML连接到一个名为mapcontent.cs的视图模型。
在叫,mapcontent.cs的视图模型,我有一个属性是这样的:
public LocationRect MapArea {
get { return new LocationRect(new Location(52.716610, 6.921160), new Location(52.718330, 6.925840)); }
}
现在我想使用的setView,但是这与MVVM成立。 所以我创建的地图类的额外控制:
namespace Markarian.ViewModels.Silverlight.Controls {
/// <summary>
/// Map control class
/// </summary>
public class Map: MC.Map {
/// <summary>
/// Initializes a new instance of the Map class.
/// </summary>
public Map() {
}
/// <summary>
/// gets and sets setview.
/// </summary>
public MC.LocationRect ViewArea { get; set; } <<<setview will come here
}
}
现在的解决方案将是,我可以在我的XAML中使用ViewArea并绑定与MapArea。 唯一的问题是,我不能在XAML中使用属性Viewarea,有谁知道为什么?