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个按钮。非必要时不建议使用该方法显示消息。

你可能感兴趣的:(windows)