windows8开发学习笔记

  • XAML行列定义
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
           <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
    	</Grid.ColumnDefinitions>
     </Grid>

  • 保存配置数据
    //恢复数据
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    	ApplicationDataContainer container = ApplicationData.Current.LocalSettings;
    	if (container.Values.ContainsKey("ListBoxIndex"))
    	{
    		MyListBox.SelectedIndex = (int)ApplicationData.Current.LocalSettings.Values["ListBoxIndex"];
    	}
    }
    //保存数据
    private void MyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
    	ListBox list = sender as ListBox;
    	if (list != null)
    	{
    		if (list.SelectedIndex > -1)
    		{
    			ApplicationDataContainer myContainer = ApplicationData.Current.LocalSettings;
    			myContainer.Values["ListBoxIndex"] = list.SelectedIndex;
    		}
    	} 
    }

  • MessageDialog
    private /*async*/ void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
            {
                MessageDialog msg = new MessageDialog("测试成功.");
                msg.Commands.Add(new UICommand("Yes"));
                msg.Commands.Add(new UICommand("No"));
                msg.Commands.Add(new UICommand("林武"));
                /*IUICommand result =await*/ msg.ShowAsync();
            }
    去掉其中的注释后,需要等待对话框显示后,函数才会执行完,使用的是异步机制同步化的方法。此外,MessageBox最多只支持3个按钮。非必要时不建议使用该方法显示消息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值