using System.Windows; using System.Windows.Controls; namespace UniversalControls.Controls; /// /// Interaction logic for BoatDiagram.xaml /// public partial class BoatDiagram : UserControl { public BoatDiagram() { InitializeComponent(); } public int Position { get { return (int)GetValue(PositionProperty); } set { SetValue(PositionProperty, value); } } // Using a DependencyProperty as the backing store for Position. This enables animation, styling, binding, etc... public static readonly DependencyProperty PositionProperty = DependencyProperty.Register(nameof(Position), typeof(int), typeof(BoatDiagram), new PropertyMetadata(3, PropertyChangedCallback)); static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not BoatDiagram boat) return; if (e.NewValue is not int pos) return; switch (pos) { case 1: boat.Core.SetValue(Canvas.TopProperty, 126d); break; case 2: boat.Core.SetValue(Canvas.TopProperty, 286d); break; case 3: boat.Core.SetValue(Canvas.TopProperty, 380d); break; default: break; } } }