0
我得到了Silverlight地圖控件,我想訪問BoundingRectangle屬性。但它不是一個依賴屬性。 所以我的目標是創建一個附屬屬性,它綁定到ViewModel中的一個屬性。每次調用這個屬性時,DepdendencyProperty Getter應該返回Map Element的BoundingRectangle屬性。 但可悲的是,吸氣不叫......依賴屬性獲取調用
我的繼承人代碼
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;
}
我希望你能幫助我:)