zoukankan      html  css  js  c++  java
  • Caliburn.Micro for wp7 学习笔记(2) : 响应 Butto事件

    在上一个文章中我们创建了一个基于 Caliburn.Micro 框架的 wp7 程序

    这章我们将来学习 Caliburn.Micro 框架下 的事件响应

    一般第一个例子都是Hello, World 所以设想是这样的,页面上有一个按钮,我们点击按钮弹出一个MessageBox 显示 "Hello  World"

    现在打开我们建立的工程

    将MainPage.xaml 页面中的 controls:Panorama  删除

    剩下个干净的页面,然后从工具箱拖出一个button

    现在你的代码应该像这样

    <phone:PhoneApplicationPage 
        x:Class="WP7App1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
        FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait"  Orientation="Portrait"
        shell:SystemTray.IsVisible="False">
       
        <Grid x:Name="LayoutRoot" Background="Transparent">
      
            <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="128,308,0,0" Name="button1" VerticalAlignment="Top" Width="160" />
        
        </Grid>
      
    </phone:PhoneApplicationPage>

    然后打开ViewModels 目录下的 MainPageViewModel.cs

    在里面添加如下代码

            public void button1()
            {
    
                MessageBox.Show("Hello  World");
    
            }

    然后运行 ,点击Button按钮,你的程序现在应该如下显示

     很简便吧,下一个文章我将分析下它的原理

  • 相关阅读:
    钾 动态规划
    镁 细节
    锌 填坑计划
    钠 GZY整理贪心
    javascript+Java 实现MD5加密登录密码
    FCKeditor2.6.4图片上传,中文名乱码,红叉各种问题解决
    Java 随机生成验证码,支持大小写字母、数字、随机字体
    BI BI系统监控
    使用ETL控件还是存储过程
    fsync与数据库日志刷新
  • 原文地址:https://www.cnblogs.com/iiixxxiii/p/2492657.html
Copyright © 2011-2022 走看看