| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Windows;
- using System.Windows.Controls;
- namespace UniversalControls.Controls;
- /// <summary>
- /// Interaction logic for BoatDiagram.xaml
- /// </summary>
- 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;
- }
- }
- }
|