todo stage1
This commit is contained in:
68
MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
Normal file
68
MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user