zoukankan      html  css  js  c++  java
  • Windows Phone开发笔记1:基础使用

    接触了Win8 Metro开发和Windows Phone 7的开发已经有差不多两个月了,一直只是浅层地了解其中的一些工具使用。下面写的内容很杂很乱。

    1. 模拟器参数示意图:

    Frame Rate Counters with Labels

    2. 在App中显示App使用的内存和峰值内存,每2秒更新一次(以MB为单位)。

        public partial class MainPage : PhoneApplicationPage
        {
            DispatcherTimer timer;
            // Constructor
            public MainPage()
            {
                InitializeComponent();
                timer = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 2);
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
    
                // Set the data context of the listbox control to the sample data
                DataContext = App.ViewModel;
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }
            void timer_Tick(object sender, EventArgs e)
            {
                try
                {
                    // These are TextBlock controls that are created in the page’s XAML file.      
                    MemoryTextBlock.Text = (Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage / 1048576).ToString();
                    PeakMemoryTextBlock.Text = (Microsoft.Phone.Info.DeviceStatus.ApplicationPeakMemoryUsage / 1048576).ToString();
                }
                catch (Exception ex)
                {
                    MemoryTextBlock.Text = ex.Message;
                }
            }
            // Load data for the ViewModel Items
            private void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                if (!App.ViewModel.IsDataLoaded)
                {
                    App.ViewModel.LoadData();
                }
            }
        }

    使用时请在XAML中添加x:Name分别是MemoryTextBlock和PeakMemoryTextBlock的两个控件。

  • 相关阅读:
    开挂的列表与矜持的元组
    烦人的字符串
    好用的for循环与range
    浅谈编码
    流程控制与循环
    基础运算符
    python初识
    python的小介绍
    来自极客标签10款最新设计素材-系列九
    chmod----改变一个或多个文件的存取模式(mode)
  • 原文地址:https://www.cnblogs.com/blastmann/p/2520491.html
Copyright © 2011-2022 走看看