zoukankan      html  css  js  c++  java
  • WPF SDK研究 Intro(4) QuickStart4

    QuickStart4
        This sample shows you how to implement a button with an associated Click event handler.
        本例介绍如何在xaml的button上绑定后台的事件

        xaml代码:
    <Page    
      xmlns
    ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x
    ="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Class
    ="QuickStart_4.Page1">
        
    <StackPanel>
            
    <Button HorizontalAlignment="Left"
                    Width
    ="100"
                    Margin
    ="10,10,10,10"
                    Click
    ="HandleClick"
                    Name
    ="Button1">Click Me</Button>
        
    </StackPanel>
    </Page>

        后台代码:
    namespace QuickStart_4
    {
        
    public partial class Page1 : Page
        
    {
            
    void HandleClick(object sender, RoutedEventArgs e)
            
    {
                Button1.Content 
    = "Hello World";
            }

        }

    }

        分析如下:
            xaml代码的Page标签,x:Class="QuickStart_4.Page1",指定了这个xaml文件将编译到QuickStart_4.Page1中(没有这个属性的xaml文件是在运行期动态编译的)。通过Button的Click事件,指定后台的相应方法。
            注意后台代码的事件方法,使用的是RoutedEventArgs参数,这牵扯到WPF中新的事件机制。
  • 相关阅读:
    关于异步取消线程以及异步销毁锁的探讨
    pthread_mutex_init & 互斥锁pthread_mutex_t的使用(转)
    Qt设置全局的widget的stylesheet
    浅析pthread_cond_wait(转)
    575 Skew Binary
    HDU 1229 还是A+B
    10370
    10300
    UVA 10071 Problem B Back to High School Physics
    UVA 10055 Problem A Hashmat the brave warrior
  • 原文地址:https://www.cnblogs.com/Jax/p/1096747.html
Copyright © 2011-2022 走看看