public override void OnApplyTemplate() { base.OnApplyTemplate(); //注册“清空”图标的点击事件 this.PART_ClearText = VisualHelper.FindVisualElement <Path>(this, "PART_ClearText"); if (this.PART_ClearText != null) { this.PART_ClearText.MouseLeftButtonDown += PART_ClearText_MouseLeftButtonDown; } this.PART_ScrollViewer = Utils.VisualHelper.FindVisualElement <ScrollViewer>(this, "PART_ContentHost"); //监听TextBox的鼠标滚轮滚动事件 this.PreviewMouseWheel += TitleTextBox_PreviewMouseWheel; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.PART_TextBox = VisualHelper.FindVisualElement <DatePickerTextBox>(this, "PART_TextBox_New"); this.PART_Popup = VisualHelper.FindVisualElement <Popup>(this, "PART_Popup_New"); this.PART_Calendar = GetTemplateChild("PART_Calendar") as Calendar; this.PART_TimePicker = GetTemplateChild("PART_TimePicker") as TimePicker; this.PART_Clear_Button = GetTemplateChild("PART_Clear_Button") as Button; this.PART_Today_Button = GetTemplateChild("PART_Today_Button") as Button; this.PART_Confirm_Button = GetTemplateChild("PART_Confirm_Button") as Button; if (this.PART_Calendar != null) { this.PART_Calendar.AddHandler(Button.MouseLeftButtonDownEvent, new RoutedEventHandler(DayButton_MouseLeftButtonUp), true); } if (this.PART_TimePicker != null) { this.PART_TimePicker.SelectedTimeChanged += PART_TimePicker_SelectedTimeChanged;; } if (this.PART_Popup != null) { this.PART_Popup.Opened += PART_Popup_Opened; this.PART_Popup.Closed += PART_Popup_Closed; } if (this.PART_Today_Button != null) { this.PART_Today_Button.Click += PART_Today_Button_Click; } if (this.PART_Confirm_Button != null) { this.PART_Confirm_Button.Click += PART_Confirm_Button_Click; } if (this.PART_Clear_Button != null) { this.PART_Clear_Button.Click += PART_Clear_Button_Click; } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.PART_Btn_Close = VisualHelper.FindVisualElement <Button>(this, "PART_Btn_Close"); this.PART_Btn_Minimized = VisualHelper.FindVisualElement <Button>(this, "PART_Btn_Minimized"); this.PART_Btn_Maximized = VisualHelper.FindVisualElement <Button>(this, "PART_Btn_Maximized"); this.PART_Btn_Restore = VisualHelper.FindVisualElement <Button>(this, "PART_Btn_Restore"); this.PART_TitleBar = VisualHelper.FindVisualElement <Grid>(this, "PART_TitleBar"); this.PART_Btn_More = VisualHelper.FindVisualElement <Button>(this, "PART_Btn_More"); this.PART_Popup_Menu = VisualHelper.FindVisualElement <Popup>(this, "PART_Popup_Menu"); if (this.PART_Btn_Close != null) { this.PART_Btn_Close.Click += Btn_close_Click; } if (this.PART_Btn_Maximized != null) { this.PART_Btn_Maximized.Click += PART_Btn_Maximized_Click; } if (this.PART_Btn_Restore != null) { this.PART_Btn_Restore.Click += PART_Btn_Restore_Click; } if (!this.MaximizeBox && !this.MinimizeBox && !this.CloseBox && string.IsNullOrEmpty(this.Title.Trim())) { this.PART_TitleBar.Visibility = Visibility.Collapsed; } if (this.PART_Btn_More != null) { this.PART_Btn_More.Click += PART_Btn_More_Click;; } if (this.PART_TitleBar != null) { this.PART_TitleBar.MouseLeftButtonDown += GridTitleBar_MouseLeftButtonDown; } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.PART_UP = VisualHelper.FindVisualElement <Button>(this, "PART_UP"); this.PART_DOWN = VisualHelper.FindVisualElement <Button>(this, "PART_DOWN"); if (this.PART_UP != null) { this.PART_UP.Click += BtnUp_Click; } if (this.PART_DOWN != null) { this.PART_DOWN.Click += BtnDown_Click; } this.TextChanged += NumericUpDown_TextChanged; this.KeyUp += NumericUpDown_KeyUp; this.SetBtnEnabled(this.Value.ToString()); this.MoveCursorToEnd(); this.Value = this.CoreValueCompareMinMax(this.Value); }