wpf

 

事件响应:xaml文件中。

 

<Window x:Class="myWpfone.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel Background="LightSlateGray">
            <TextBox Text="{Binding ElementName=slider1,Path=Value,Mode=OneWay}" Margin="5"/>
            <Slider x:Name="slider1" Margin="5"></Slider>
            <Button x:Name="button1" Click="button1_Click" Margin="10" Height="20" Width="100"></Button>    
        </StackPanel>
    </Grid>
    <x:Code>
        <![CDATA[
            private void button1_Click(object sender, RoutedEventArgs e)
            {
               MessageBox.Show("1");
            }
        ]]>
    </x:Code>
    
    
</Window>

事件响应:cs文件中。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace myWpfone
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("hello world!");
        }

  
    }
}

 

posted @ 2016-01-09 11:23  星雷热忱  阅读(197)  评论(0编辑  收藏  举报