1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media.Animation;
- using Jamesnet.Wpf.Animation;
- using Jamesnet.Wpf.Controls;
- namespace Waaagh.CustomControl {
- public class NavigationBar: ListBox {
- private ValueItem _vi;
- private Storyboard _sb;
- static NavigationBar() {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(NavigationBar), new FrameworkPropertyMetadata(typeof(NavigationBar)));
- }
- public override void OnApplyTemplate() {
- base.OnApplyTemplate();
- Grid grid = (Grid)GetTemplateChild("PART_Circle");
- InitStoryboard(grid);
- }
- private void InitStoryboard(Grid circle) {
- _vi = new();
- _sb = new();
- _vi.Mode = EasingFunctionBaseMode.QuinticEaseInOut;
- _vi.Property = new PropertyPath(Canvas.LeftProperty);
- _vi.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
- Storyboard.SetTarget(_vi, circle);
- Storyboard.SetTargetProperty(_vi, _vi.Property);
- _sb.Children.Add(_vi);
- }
- protected override void OnSelectionChanged(SelectionChangedEventArgs e) {
- base.OnSelectionChanged(e);
- _vi.To = SelectedIndex * 80;
- _sb.Begin();
- }
- }
- }
|