Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public partial class MyControl : UserControl
{
    static MyControl()
    {
        typeof(MyControl).AutoDetectViewPropertiesToSubscribe();
    }
 
	public MyControl()
	{
		InitializeComponent();
	}
 
	[ViewToViewModel(MappingType = ViewToViewModelMappingType.ViewModelToView)]
	public GeoCoordinate MapCenter
	{
		get { return (GeoCoordinate) GetValue(MapCenterProperty); }
		set { SetValue(MapCenterProperty, value); }
	}
 
	// Using a DependencyProperty as the backing store for MapCenter.  This enables animation, styling, binding, etc...
	public static readonly DependencyProperty MapCenterProperty = DependencyProperty.Register("MapCenter", typeof (GeoCoordinate),
		typeof (MyControl), new PropertyMetadata(null, (sender, e) => ((MyControl) sender).UpdateMapCenter()));
 
	private void UpdateMapCenter()
	{
		map.SetView(ViewModel.MapCenter, ViewModel.ZoomLevel);
	}
 
	public new MainPageViewModel ViewModel
	{
		get { return base.ViewModel as MainPageViewModel; }
	}
}

...