You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
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
|
|
{
|
|
/// <summary>
|
|
/// PlaceholderTextBox.xaml에 대한 상호 작용 논리
|
|
/// </summary>
|
|
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 Brush TForeground { get; set; } = Brushes.Gray;
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|