System.Windows.Controls.AutoCompleteBox.FocusChanged C# (CSharp) Méthode

FocusChanged() private méthode

Handles the FocusChanged event.
private FocusChanged ( bool hasFocus ) : void
hasFocus bool A value indicating whether the control /// currently has the focus.
Résultat void
        private void FocusChanged(bool hasFocus)
        {
            // The OnGotFocus & OnLostFocus are asynchronously and cannot 
            // reliably tell you that have the focus.  All they do is let you 
            // know that the focus changed sometime in the past.  To determine 
            // if you currently have the focus you need to do consult the 
            // FocusManager (see HasFocus()).

            if(hasFocus)
            {
                if(TextBox != null && TextBox.SelectionLength == 0)
                {
                    TextBox.SelectAll();
                }
            }
            else
            {
                IsDropDownOpen = false;
                _userCalledPopulate = false;
                if(TextBox != null)
                {
                    TextBox.Select(TextBox.Text.Length, 0);
                }
            }
        }