/// <summary> /// Builds the visual tree for the DatePicker control when a new template is applied. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); _dropDownButton = GetTemplateChild(DATEPICKER_elementButtonName) as Button; if (_dropDownButton != null) { _dropDownButton.MouseLeftButtonDown += new MouseButtonEventHandler(DropDownButton_MouseLeftButtonDown); _dropDownButton.KeyDown += new KeyEventHandler(DropDownButton_KeyDown); _dropDownButton.IsTabStop = false; } _rootGrid = GetTemplateChild(DATEPICKER_elementRootName) as Grid; if (_rootGrid != null) { _stateDisabled = _rootGrid.Resources[DATEPICKER_stateDisabledName] as Storyboard; _stateNormal = _rootGrid.Resources[DATEPICKER_stateNormalName] as Storyboard; _rootGrid.SizeChanged += new SizeChangedEventHandler(RootGrid_SizeChanged); } _textBox = GetTemplateChild(DATEPICKER_elementTextBoxName) as WatermarkedTextBox; _disabledVisual = GetTemplateChild("DisabledVisual") as FrameworkElement; UpdateDisabledVisual(this.IsEnabled); this._calendarMode = CalendarMode.Month; this.MouseLeftButtonDown += new MouseButtonEventHandler(DatePicker_MouseLeftButtonDown); this.IsTabStop = true; SetWaterMarkText(); if (_textBox != null) { _textBox.KeyDown += new KeyEventHandler(TextBox_KeyDown); _textBox.IsTabStop = true; if (this.SelectedDate == null) { if (!string.IsNullOrEmpty(this._defaultText)) { _textBox.Text = this._defaultText; } } else { _textBox.Text = this.DateTimeToString((DateTime)this.SelectedDate); } } }
public SearchSpriteItem(double panelWidth) { var inputScope = new InputScope(); var searchNameValue = new InputScopeName { NameValue = InputScopeNameValue.Search }; inputScope.Names.Add(searchNameValue); _searchBox = new WatermarkedTextBox { FontSize = 17.778, Watermark = AppResources.Search, InputScope = inputScope, Style = (Style)Application.Current.Resources["W10MWatermarkedTextBoxStyle"] }; _searchBox.GotFocus += (sender, args) => { RaiseOpenFullScreen(); }; _searchBox.LostFocus += (sender, args) => { //RaiseCloseFullScreen(); }; _searchBox.KeyUp += (sender, args) => { var text = _searchBox.Text; Api.Helpers.Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), () => { if (!string.Equals(text, _searchBox.Text)) { return; } RaiseSearchText(new SearchTextEventArgs { Text = text }); }); }; Children.Add(_searchBox); View.Width = panelWidth; }