<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="storyboard.clear"
x:Name="Window"
Title="clear"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<Button x:Name="btn_a" Content="A" Height="56" Margin="208,149,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75" Click="btn_a_Click" />
<TextBox x:Name="txt_display" Height="50" Margin="208,57,252,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
<Button x:Name="btn_b" Content="B" Height="56" Margin="297,149,252,0" VerticalAlignment="Top" Click="btn_b_Click" />
</Grid>
public partial class clear : Window
{
public clear()
{
this.InitializeComponent();
}
private void btn_a_Click(object sender, RoutedEventArgs e)
{
txt_display.Text += btn_a.Content.ToString();
txt_display.SelectionStart = txt_display.Text.Length;
txt_display.Focus();
}
private void btn_b_Click(object sender, RoutedEventArgs e)
{
txt_display.Text += btn_b.Content.ToString();
txt_display.SelectionStart = txt_display.Text.Length;
txt_display.Focus();
}
}
在这里,我想绑定鼠标选择开始的按钮内容,如上图。
但我无法解决这种情况。
请帮我。