コード例 #1
0
        private static void OnWatermarkChanged(DependencyObject sender, DependencyPropertyChangedEventArgs ea)
        {
            WatermarkTextBox textBox = sender as WatermarkTextBox;

            if (textBox.IsWatermarkShown)
            {
                textBox.ShowWatermark();
            }
        }
コード例 #2
0
        private static void OnKeyboardFocusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            WatermarkTextBox tb = d as WatermarkTextBox;

            tb.ShowCaret();
            if (tb.KeyboardFocus)
            {
                RoutedEventArgs newEventArgs = new RoutedEventArgs(WatermarkTextBox.KeyboardFocusEvent);
                tb.RaiseEvent(newEventArgs);
            }
        }
コード例 #3
0
        private void contentHost_TouchDown(object sender, TouchEventArgs e)
        {
            Control content = sender as Control;

            if (null != content)
            {
                TouchPoint tp     = e.GetTouchPoint(content);
                Rect       bounds = new Rect(new Point(0, 0), content.RenderSize);
                if (bounds.Contains(tp.Position))
                {
                    WatermarkTextBox tb = content.TemplatedParent as WatermarkTextBox;
                    if (null != tb)
                    {
                        tb.KeyboardFocus = true;
                    }
                }
                content.ReleaseTouchCapture(e.TouchDevice);
            }
        }
コード例 #4
0
        private void TextBox_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            WatermarkTextBox tb = sender as WatermarkTextBox;

            tb.ShowCaret();
        }
コード例 #5
0
        private static void OnWatermarkBorderColorChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            WatermarkTextBox textBox = sender as WatermarkTextBox;

            textBox.BorderBrush = textBox.WatermarkBorderColor;
        }