silverlight 按回车键响应登陆按钮 代码怎么写
展开全部
写了的demo给你
前台:
<UserControl ..................KeyDown="UserControl_KeyDown">
<Grid x:Name="LayoutRoot" Background="White">腔燃历
<Button Name="btn" Width="100" Height="28" Click="Button_Click">Button</Button>
</Grid>
</UserControl> 就是在页面的最顶层加KeyDown事件
后台:
public partial class Test : UserControl
{
public Test()
{
InitializeComponent();
}
private void UserControl_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Button_Click(sender,new RoutedEventArgs());
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("hello");
}
}
当登入框捕捉到keydown事件后,触发登陆按段袭钮的点击事伍搜件即可!~
前台:
<UserControl ..................KeyDown="UserControl_KeyDown">
<Grid x:Name="LayoutRoot" Background="White">腔燃历
<Button Name="btn" Width="100" Height="28" Click="Button_Click">Button</Button>
</Grid>
</UserControl> 就是在页面的最顶层加KeyDown事件
后台:
public partial class Test : UserControl
{
public Test()
{
InitializeComponent();
}
private void UserControl_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Button_Click(sender,new RoutedEventArgs());
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("hello");
}
}
当登入框捕捉到keydown事件后,触发登陆按段袭钮的点击事伍搜件即可!~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询