我得到了 Silverlight 地图控件,我想访问 BoundingRectangle 属性。但这不是依赖属性。所以我的强项是创建一个附加属性,该属性绑定到我的 ViewModel 中的一个属性。并且每次调用此属性时,DepdendencyProperty Getter 都应返回地图元素的 BoundingRectangle 属性。但遗憾的是,没有调用 Getter...
这是我的代码
public class MapHelper
{
public static readonly DependencyProperty MapViewRectangleProperty =
DependencyProperty.RegisterAttached(
"MapViewRectangle",
typeof(LocationRect),
typeof(MapHelper),
new PropertyMetadata(null, new PropertyChangedCallback(MapViewRectanglePropertyChanged))
);
private static void MapViewRectanglePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
string balls = "balls";
}
public static void SetMapViewRectangle(object element, LocationRect value)
{
string balls = "balls";
}
public static LocationRect GetMapViewRectangle(object element)
{
if (element is Map)
{
return (LocationRect)(((Map)element).TargetBoundingRectangle);
}
else
{
return null;
}
}
}
XAML:
<m:Map utils:MapHelper.MapViewRectangle="{Binding Path=BoundingRectangle}" />
视图模型:
public LocationRect BoundingRectangle
{
get;
set;
}
我希望你能帮帮我 :)