When i went to add an event to the button which i dragged and dropped from toolbox to the window, the event handler on the properties window was not visible.. because of this reason, i added the event manually (by typing). but after when i built it and pressed F5, the button was not firing the event.
here is a little example that must be work ;-)
<Window x:Class="WpfStackOverflowSpielWiese.Window8"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window8"
Height="300"
Width="300">
<Grid>
<Button Click="Button_Click" />
</Grid>
</Window>
code behind
using System.Windows;
namespace WpfStackOverflowSpielWiese
{
/// <summary>
/// Interaction logic for Window8.xaml
/// </summary>
public partial class Window8 : Window
{
public Window8() {
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e) {
// do something....
}
}
}
hope that helps you...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.