Пример #1
0
        private static void OnIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SlideSwitchPanel panel = d as SlideSwitchPanel;

            if (e.Property == SlideSwitchPanel.IndexProperty)
            {
                int newValue = (int)e.NewValue;
                int oldValue = (int)e.OldValue;
                panel.OnIndexChanged(oldValue, newValue);
            }
        }
Пример #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.PART_SlideSwitchPanel = this.GetTemplateChild("PART_SlideSwitchPanel") as SlideSwitchPanel;
            this.PART_IndexPanel       = this.GetTemplateChild("PART_IndexPanel") as StackPanel;
            this.PART_LastButton       = this.GetTemplateChild("PART_LastButton") as Button;
            this.PART_NextButton       = this.GetTemplateChild("PART_NextButton") as Button;

            this.GroupName = Guid.NewGuid().ToString("N");

            this.AddChildToPanel();
            this.AddIndexControlToPanel();

            if (this.PART_SlideSwitchPanel != null)
            {
                this.PART_SlideSwitchPanel.IndexChanged += PART_SlideSwitchPanel_IndexChanged;
            }

            this.MouseEnter += PART_SlideSwitchPanel_MouseEnter;
            this.MouseLeave += PART_SlideSwitchPanel_MouseLeave;

            if (this.PART_IndexPanel != null && this.PART_IndexPanel.Children.Count > 0)
            {
                ((RadioButton)this.PART_IndexPanel.Children[0]).IsChecked = true;
            }

            if (this.PART_LastButton != null)
            {
                this.PART_LastButton.Click += PART_LastButton_Click;
            }
            if (this.PART_NextButton != null)
            {
                this.PART_NextButton.Click += PART_NextButton_Click;
            }

            VisualStateManager.GoToState(this, "Normal", true);
        }
Пример #3
0
        private void PART_SlideSwitchPanel_IndexChanged(object sender, RoutedPropertyChangedEventArgs <int> e)
        {
            SlideSwitchPanel panel = sender as SlideSwitchPanel;

            this.SetIndexPanelChecked(panel.Index);
        }