Microsoft.Phone.Controls.PhoneTextBox.UpdateHintVisibility C# (CSharp) Method

UpdateHintVisibility() private method

Determines if the Hint should be shown or not based on if there is content in the TextBox.
private UpdateHintVisibility ( ) : void
return void
        private void UpdateHintVisibility()
        {
            if (_hintContent != null)
            {
                if (string.IsNullOrEmpty(Text))
                {
                    ActualHintVisibility = Visibility.Visible;
                    Foreground = _foregroundBrushInactive;
                }
                else
                {
                    ActualHintVisibility = Visibility.Collapsed;
                    Foreground = _foregroundBrushEdit;
                }
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// When the Hint is changed, check if it needs to be hidden or shown.
        /// </summary>
        /// <param name="sender">Sending PhoneTextBox.</param>
        /// <param name="args">DependencyPropertyChangedEvent Arguments.</param>
        private static void OnHintPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            PhoneTextBox phoneTextBox = sender as PhoneTextBox;

            if (phoneTextBox != null && phoneTextBox.HintContent != null)
            {
                phoneTextBox.UpdateHintVisibility();
            }
        }