У меня есть элемент управления Silverlight Map, и я хочу получить доступ к свойству BoundingRectangle. Но это не зависимость. Так что мне пришлось создавать атташе собственности, которая связана с собственностью в моей модели ViewModel. И каждый раз, когда это свойство называется DepdendencyProperty, Getter должен вернуть свойство BoundingRectangle элемента карты. Но, к сожалению геттер не называется ...Зависимость собственности Getter Call
Heres мой код
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}" />
ViewModel:
public LocationRect BoundingRectangle
{
get;
set;
}
Я надеюсь, что вы можете мне помочь)