【问题标题】:WPF event handler in Visual Studio 2008?Visual Studio 2008 中的 WPF 事件处理程序?
【发布时间】:2012-02-08 06:30:04
【问题描述】:

当我将事件添加到从工具箱拖放到窗口的按钮时,属性窗口上的事件处理程序不可见..由于这个原因,我手动添加了事件(通过键入) .但是当我构建它并按下 F5 之后,按钮没有触发事件。

【问题讨论】:

  • 你必须在 XAML 和 C# 中处理事件。

标签: c# wpf visual-studio-2008


【解决方案1】:

这是一个必须工作的小例子;-)

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

希望对你有所帮助...

【讨论】:

  • 我自己解决了 :-) ...我所做的是将我的 Visual Studio 2008 更新到 SP1。现在事件处理程序在属性窗口中..一切正常..谢谢大家来帮助我。干杯!!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-09
  • 1970-01-01
  • 2012-01-20
相关资源
最近更新 更多