public partial class MultiTexbox_2 : Window
{
Control texbox_full_details = null; //get all textbox property and method in when gotfocused
Control button_full_details; //get all button property and method in when click event
Button keyboard_button; //behave like button
public MultiTexbox_2()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void btn_a_Click(object sender, RoutedEventArgs e)
{
button_full_details = (Control)sender;
all_in_one();
//var caretIndex = txt_diplay_1.CaretIndex;
//txt_diplay_1.Text = txt_diplay_1.Text.Insert(caretIndex, btn_a.Content.ToString());
//txt_diplay_1.Focus();
//txt_diplay_1.CaretIndex = caretIndex + 1;
}
private void btn_b_Click(object sender, RoutedEventArgs e)
{
button_full_details = (Control)sender;
all_in_one();
}
private void btn_c_Click(object sender, RoutedEventArgs e)
{
button_full_details = (Control)sender;
all_in_one();
}
private void txt_diplay_1_GotFocus(object sender, RoutedEventArgs e)
{
texbox_full_details = (Control)sender;
}
private void txt_diplay_2_GotFocus(object sender, RoutedEventArgs e)
{
texbox_full_details = (Control)sender;
}
public void all_in_one()
{
keyboard_button = button_full_details as Button;
if (texbox_full_details != null)
{
//TextBox tb = texbox as TextBox;
//tb.Text += btn.Content;
TextBox txt_box = texbox_full_details as TextBox;
var caret_index = txt_box.CaretIndex;
txt_box.Text = txt_box.Text.Insert(caret_index, keyboard_button.Content.ToString());
txt_box.Focus();
txt_box.CaretIndex = caret_index + 1;
}
}
}
出力はこんな感じになります
しかし、このような出力が必要です
ボタンをクリックすると、コンテンツがテキストボックスにバインドされます。その時点で、現在バインドされているテキストボックステキストの背景色、フォントの色、フォントサイズが変更されます。そのような出力を取得するにはどうすればよいですか。助けてください。