Watermark textbox in wpf
Watermark textbox in wpf
This is a sample which demonstrates how to create a watermark textbox in WPF:Create : WatermarkTextBox.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Controls { public class WatermarkTextBox : TextBox { static WatermarkTextBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(WatermarkTextBox), new FrameworkPropertyMetadata(typeof(WatermarkTextBox))); } public object Watermark { get { return (object)GetValue(WatermarkProperty); } set { SetValue(WatermarkProperty, value); } } // Using a DependencyProperty as the backing store for Watermark. This enables animation, styling, binding, etc... public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register( "Watermark", typeof(object), typeof(WatermarkTextBox), new UIPropertyMetadata(null)); } }Output
Download : Here
Watermark textbox in wpf
Reviewed by Bhaumik Patel
on
7:11 PM
Rating: