2012-02-08 92 views
0

當我去添加一個事件的按鈕,我從工具箱拖放到窗口,屬性窗口上的事件處理程序不可見..因爲這個原因,我手動添加事件(通過鍵入)。但是當我建立它並按下F5後,按鈕不會觸發事件。Visual Studio 2008中的WPF事件處理程序?

+0

你必須在XAML和事件C#。 – Hadas 2012-02-08 06:33:51

+2

需要代碼示例。 – grimstoner 2012-02-08 06:48:13

回答

0

這裏是一個小的例子,必須是工作;-)

<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> 

代碼背後

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.... 
    } 
    } 
} 

希望幫助你...

+0

我自己解決了它:-) ...我做的是我更新了我的視覺工作室2008 SP1。現在事件處理程序在那裏的屬性窗口..一切工作正常..謝謝你來幫助我。乾杯!!!! – MJA 2012-02-08 14:06:29