markus / KCOM / Controls / ExtendTextBox.xaml.cs @ b7645ccc
이력 | 보기 | 이력해설 | 다운로드 (2.48 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Windows; |
7 |
using System.Windows.Controls; |
8 |
using System.Windows.Data; |
9 |
using System.Windows.Documents; |
10 |
using System.Windows.Input; |
11 |
using System.Windows.Media; |
12 |
using System.Windows.Media.Imaging; |
13 |
using System.Windows.Navigation; |
14 |
using System.Windows.Shapes; |
15 |
|
16 |
namespace KCOM.Controls |
17 |
{ |
18 |
/// <summary> |
19 |
/// UseLInesTextBox.xaml에 대한 상호 작용 논리 |
20 |
/// </summary> |
21 |
public partial class ExtendTextBox : UserControl |
22 |
{ |
23 |
public ExtendTextBox() |
24 |
{ |
25 |
InitializeComponent(); |
26 |
} |
27 |
|
28 |
private string tempString; |
29 |
|
30 |
public bool IsExtend |
31 |
{ |
32 |
get { return (bool)GetValue(IsExtendProperty); } |
33 |
set { SetValue(IsExtendProperty, value); } |
34 |
} |
35 |
|
36 |
public static readonly DependencyProperty IsExtendProperty = |
37 |
DependencyProperty.RegisterAttached("IsExtend", typeof(bool), typeof(ExtendTextBox), new PropertyMetadata(false, IsExtendPropertyChanged)); |
38 |
|
39 |
private static void IsExtendPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
40 |
{ |
41 |
var owner = d as ExtendTextBox; |
42 |
owner.SetTextBox(); |
43 |
} |
44 |
|
45 |
public string Text |
46 |
{ |
47 |
get { return (string)GetValue(TextProperty); } |
48 |
set { SetValue(TextProperty, value); } |
49 |
} |
50 |
|
51 |
public static readonly DependencyProperty TextProperty = |
52 |
DependencyProperty.RegisterAttached("Text", typeof(string), typeof(ExtendTextBox), new PropertyMetadata(null, TextPropertyChanged)); |
53 |
|
54 |
private static void TextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
55 |
{ |
56 |
var owner = d as ExtendTextBox; |
57 |
|
58 |
owner.tempString = (string)e.NewValue; |
59 |
owner.SetTextBox(); |
60 |
} |
61 |
|
62 |
private void SetTextBox() |
63 |
{ |
64 |
if (!IsExtend) |
65 |
{ |
66 |
btExtend.Content = "+"; |
67 |
txtBox.Text = tempString?.Split(System.Environment.NewLine.ToCharArray()).First(); |
68 |
} |
69 |
else |
70 |
{ |
71 |
btExtend.Content = "-"; |
72 |
txtBox.Text = tempString; |
73 |
} |
74 |
} |
75 |
|
76 |
|
77 |
public override void OnApplyTemplate() |
78 |
{ |
79 |
base.OnApplyTemplate(); |
80 |
} |
81 |
|
82 |
private void Button_Click(object sender, RoutedEventArgs e) |
83 |
{ |
84 |
IsExtend = !IsExtend; |
85 |
} |
86 |
} |
87 |
} |