using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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 ToDoApp.SubControl { /// /// PlaceholderTextBox.xaml에 대한 상호 작용 논리 /// public partial class PlaceholderTextBox : UserControl { public string TPlaceholder { get; set; } = ""; public int TFontSize { get; set; } = 12; public FontWeight TFontWeight { get; set; } = FontWeights.Normal; public int THeight { get; set; } = 20; public VerticalAlignment TVerticalAlignment { get; set; } = VerticalAlignment.Center; public PlaceholderTextBox() { InitializeComponent(); this.DataContext = this; } public string Text { get { return tbxMain.Text; } set { tbxMain.Text = value; } } private void tbxMain_GotFocus(object sender, RoutedEventArgs e) { TextBox textBox = sender as TextBox; if (textBox == null) return; if (textBox.Text != this.TPlaceholder) return; textBox.Text = ""; textBox.Foreground = Brushes.Black; } private void tbxMain_LostFocus(object sender, RoutedEventArgs e) { TextBox textBox = sender as TextBox; if (textBox == null) return; if (!string.IsNullOrEmpty(textBox.Text)) return; textBox.Text = this.TPlaceholder; textBox.Foreground = Brushes.Gray; } } }