Example #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            DependencyObject child = VisualTreeHelper.GetChild(this, 0);

            this.TextField   = LogicalTreeHelper.FindLogicalNode(child, "PART_ContentHost") as OverlayTextBox;
            this.ClearButton = LogicalTreeHelper.FindLogicalNode(child, "ClearSearchButton") as Button;
            if (this.FocusOnLoaded && !this.focusedAfterLoaded)
            {
                UIThreadDispatcher.Instance.BeginInvoke <bool>(DispatcherPriority.Loaded, () => this.TextField.Focus());
            }
        }
Example #2
0
        public static void OnTextChangedCallback(object sender, DependencyPropertyChangedEventArgs args)
        {
            OverlayTextBox overlayTextBox = sender as OverlayTextBox;

            if (overlayTextBox != null)
            {
                bool flag = !string.IsNullOrEmpty(overlayTextBox.Text);
                if (flag != overlayTextBox.HasText)
                {
                    overlayTextBox.SetValue(OverlayTextBox.HasTextPropertyKey, flag);
                }
            }
        }