簡體   English   中英

Visual Studio 2008中的WPF事件處理程序?

[英]WPF event handler in Visual Studio 2008?

當我將事件添加到從工具箱拖放到窗口的按鈕上時,屬性窗口上的事件處理程序不可見..由於這個原因,我手動添加了事件(通過鍵入)。 但是當我建造它並按下F5之后,該按鈕沒有觸發該事件。

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

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

希望對您有幫助...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM