• UWP 利用DataGrid控件创建表格


    通过 Nuget 搜索 Microsoft.Toolkit.Uwp.UI.Controls.DataGrid 安装库,在XAML文件中添加引用库

    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
     
    <Page
        x:Class="App2.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App2"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Grid>
            <controls:DataGrid x:Name="DataGrid" >
    
            </controls:DataGrid>
        </Grid>
    </Page>
    using System.Collections.Generic;
    using Windows.UI.Xaml.Controls;
    
    // https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板
    
    namespace App2
    {
        /// <summary>
        /// 可用于自身或导航至 Frame 内部的空白页。
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
    
                DataGrid.ItemsSource = new List<Foo>()
                {
                    new Foo(){ Name = "小明", Age = 15 },
                    new Foo(){ Name = "小王", Age = 16 },
                };
            }
    
            public class Foo
            {
                public string Name { get; set; }
    
                public int Age { get; set; }
            }
        }
    }
  • 相关阅读:
    php解析xml文件的方法
    while倒数阶乘的和
    菱形代码
    0929课堂随记
    0929作业
    0928练习作业
    HelloJava
    Java例题
    Hello World(本博客启程篇)
    vue 如何实现在函数中触发路由跳转
  • 原文地址:https://www.cnblogs.com/lizhiqiang0204/p/10894671.html
Copyright © 2020-2023  润新知