コード例 #1
0
        private static void UpdateIsShowing(TextBox textBox)
        {
            if (textBox == null)
            {
                return;
            }

            if (!textBox.IsVisible || !textBox.IsLoaded || string.IsNullOrEmpty(GetText(textBox)))
            {
                textBox.SetIsShowing(false);
            }
            else
            {
                switch (textBox.GetVisibleWhen())
                {
                    case WatermarkVisibleWhen.Empty:
                        textBox.SetIsShowing(string.IsNullOrEmpty(textBox.Text));
                        break;
                    case WatermarkVisibleWhen.EmptyAndNotKeyboardFocused:
                        textBox.SetIsShowing(string.IsNullOrEmpty(textBox.Text) && !textBox.IsKeyboardFocused);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }