zoukankan      html  css  js  c++  java
  • Win8开发笔记1 打开新页面并做简单控制

    作为一个从C++转向C#来学Win8开发的菜鸟,每个小步骤都是个巨大的进步啊,所以开博记录学习笔记,无关于简单复杂,只在乎过程及结果。 

    1. 新建项目,选择Visual C# -> Blank App(XAML) -> 确定; 

     2. 右击解决方案下面的App3,选择“添加项”,出现新建项目对话框:新建空白页;

     

    3. 双击MainPage.xaml,在设计器里添加按钮控件;

    4. 选中按钮控件,点击属性栏中闪电符号,在该页Click后面填OnBtn并回车,进入OnBtn函数并添加代码:      

    private void OnBtn(object sender, RoutedEventArgs e)
    {
        var rootFrame = new Frame();
        if (!rootFrame.Navigate(typeof(BlankPage1)))
        {
            throw new Exception("Failed to create initial page");
        } 
        // Place the frame in the current Window and ensure that it is active
        Window.Current.Content = rootFrame;
        Window.Current.Activate();
    }

    5. 在新页面中添加两控件:Button和TextBox,更改TextBox属性为textbox1,双击Button添加消息响应函数,并添加代码:   

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        textbox1.Text = "这是一个新页面";
    }

    6. 至此完成。遗留问题:怎么关闭页面?

  • 相关阅读:
    C++中unique函数的用法总结
    洛谷P1039侦探推理题解
    洛谷P1040 加分二叉树题解
    洛谷P1038 神经网络题解
    emmm
    biiset用法
    浅谈接口与抽象类的区别
    递归调用——数学观点看递归
    反转字符串
    SQL 时间戳转DateTime类型
  • 原文地址:https://www.cnblogs.com/Roarsun/p/2825713.html
Copyright © 2011-2022 走看看