WPF实战学习笔记05-首页界面

首页界面

新建文件

  • 添加文件[类型:用户控件]

    ./Common/Models/TaskBars.cs

    ./Common/Models/ToDoDto.cs

    ./Common/Models/MemoDto.cs

新建类

TaskBars.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Common.Models
{public class TaskBar{private string? title;private string? content;private string? target;private string? color;private string? icon;public string? Icon{get { return icon; }set { icon = value; }}public string? Title{get { return title; }set { title = value; }}public string? Content{get { return content; }set { content = value; }}public string? Color{get { return color; }set { color = value; }}public string? Target{get { return target; }set { target = value; }}}
}

TodoDto.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Common.Models
{public class ToDoDto:BaseTodo{private string? title;private string? content;private int status;public int Status{get { return status; }set { status = value; }}public string? Content{get { return content; }set { content = value; }}public string? Title{get { return title; }set { title = value; }}}
}

MemoDto.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Common.Models
{/// <summary>/// 备忘录/// </summary>public class MemoDto:BaseTodo{private string? title;private string? content;private int status;public int Status{get { return status; }set { status = value; }}public string? Content{get { return content; }set { content = value; }}public string? Title{get { return title; }set { title = value; }}}
}

BaseTodo.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Common.Models
{public   class BaseTodo{private int id;private DateTime createDate;private DateTime updateDate;/// <summary>/// 项修改日期/// </summary>public DateTime UpdateDate{get { return updateDate; }set { updateDate = value; }}/// <summary>/// 项创建时间/// </summary>public DateTime CreateDate{get { return createDate; }set { createDate = value; }}/// <summary>/// 项ID/// </summary>public int Id{get { return id; }set { id = value; }}}
}

创建TaskBars集合变量并初始化

创建变量

  • IndexViewModel

    private ObservableCollection<TaskBar> taskBars;
    

初始化

  • IndexViewModel(代码在构造函数中)
TaskBars=new ObservableCollection<TaskBar>();
TaskBars.Add(new TaskBar { Icon = "CalendarBlankOutline", Title = "汇总", Color = "#FF00FF00", Content = "27", Target = "" });
TaskBars.Add(new TaskBar { Icon = "CalendarMultipleCheck", Title = "已完成", Color = "#6B238E", Content = "24", Target = "" });
TaskBars.Add(new TaskBar { Icon = "ChartLine", Title = "完成比例", Color = "#32CD99", Content = "100%", Target = "" });
TaskBars.Add(new TaskBar { Icon = "CheckboxMarked", Title = "备忘录", Color = "#5959AB", Content = "13", Target = "" });

创建todoDtos、memoDtos集合变量并初始化

  • IndexViewModel

    private ObservableCollection<ToDoDto> todoDtos;
    private ObservableCollection<MemoDto> memoDtos;
    public ObservableCollection<MemoDto> MemoDtos
    {get { return memoDtos; }set { memoDtos = value; RaisePropertyChanged(); }
    }public ObservableCollection<ToDoDto> TodoDtos
    {get { return todoDtos; }set { todoDtos = value; RaisePropertyChanged(); }
    }
    void CreatTestData()
    {TodoDtos = new ObservableCollection<ToDoDto>();MemoDtos = new ObservableCollection<MemoDto>();for (int i = 0; i < 20; i++){TodoDtos.Add(new ToDoDto() { Title = "待办" + i, Content = "正在处理中....." });MemoDtos.Add(new MemoDto() { Title = "备忘" + i, Content = "正在忘记中....." });}
    }
    public IndexViewModel()
    {Title = "您好,2022";TaskBars=new ObservableCollection<TaskBar>();TaskBars.Add(new TaskBar { Icon = "CalendarBlankOutline", Title = "汇总", Color = "#FF00FF00", Content = "27", Target = "" });TaskBars.Add(new TaskBar { Icon = "CalendarMultipleCheck", Title = "已完成", Color = "#6B238E", Content = "24", Target = "" });TaskBars.Add(new TaskBar { Icon = "ChartLine", Title = "完成比例", Color = "#32CD99", Content = "100%", Target = "" });TaskBars.Add(new TaskBar { Icon = "CheckboxMarked", Title = "备忘录", Color = "#5959AB", Content = "13", Target = "" });CreatTestData();
    }
    

定义界面

<UserControlx:Class="Mytodo.Views.IndexView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:local="clr-namespace:Mytodo.Views"xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"d:DesignHeight="450"d:DesignWidth="800"mc:Ignorable="d"><Grid><Grid.RowDefinitions><RowDefinition Height="auto" /><RowDefinition Height="auto" /><RowDefinition /></Grid.RowDefinitions><TextBlockMargin="20,10"FontSize="30"Text="{Binding Title}" /><ItemsControl Grid.Row="1" ItemsSource="{Binding TaskBars}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><UniformGrid Columns="4" /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.ItemTemplate><DataTemplate><BorderMargin="10"Background="{Binding Color}"CornerRadius="5"><Border.Style><Style TargetType="Border"><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Effect"><Setter.Value><DropShadowEffectBlurRadius="10"ShadowDepth="1"Color="#dddddd" /></Setter.Value></Setter></Trigger></Style.Triggers></Style></Border.Style><Grid><StackPanel Margin="20"><materialDesign:PackIconWidth="25"Height="30"Margin="5"Kind="{Binding Icon}" /><TextBlockMargin="5"FontSize="10"Text="{Binding Title}" /><TextBlockMargin="5"FontSize="30"Text="{Binding Content}" /></StackPanel><Canvas ClipToBounds="True"><BorderCanvas.Top="10"Canvas.Right="-50"Width="120"Height="120"Background="#FFFFFF"CornerRadius="100"Opacity="0.1" /><BorderCanvas.Top="80"Canvas.Right="-30"Width="120"Height="120"Background="#FFFFFF"CornerRadius="100"Opacity="0.1" /></Canvas></Grid></Border></DataTemplate></ItemsControl.ItemTemplate></ItemsControl><Grid Grid.Row="2"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition /></Grid.ColumnDefinitions><BorderGrid.Column="0"Margin="10,20"Background="#bebebe"CornerRadius="5"Opacity="0.1" /><BorderGrid.Column="1"Margin="10,20"Background="#bebebe"CornerRadius="5"Opacity="0.1" /><DockPanel Margin="10,0"><DockPanelGrid.Column="0"Margin="10,20"DockPanel.Dock="Top"LastChildFill="False"><TextBlockMargin="10"FontFamily="微软雅黑"FontSize="25"FontWeight="Bold"Text="待办事项" /><ButtonWidth="30"Height="30"Margin="10"VerticalAlignment="Top"Content="{materialDesign:PackIcon Kind=Add}"DockPanel.Dock="Right"Style="{StaticResource MaterialDesignFloatingActionAccentButton}" /></DockPanel><ListBoxMargin="5"HorizontalContentAlignment="Stretch"ItemsSource="{Binding MemoDtos}"ScrollViewer.VerticalScrollBarVisibility="Hidden"><ListBox.ItemTemplate><DataTemplate><DockPanel LastChildFill="False"><ToggleButton Width="40" DockPanel.Dock="Right" /><StackPanel><TextBlock FontSize="14" Text="{Binding Title}" /><TextBlockFontSize="24"Opacity="0.5"Text="{Binding Content}" /></StackPanel></DockPanel></DataTemplate></ListBox.ItemTemplate></ListBox></DockPanel><DockPanel Grid.Column="1" Margin="10,0"><DockPanelMargin="10,20"DockPanel.Dock="Top"LastChildFill="False"><TextBlockMargin="10"FontFamily="微软雅黑"FontSize="25"FontWeight="Bold"Text="备忘录" /><ButtonWidth="30"Height="30"Margin="10"VerticalAlignment="Top"Content="{materialDesign:PackIcon Kind=Add}"DockPanel.Dock="Right"Style="{StaticResource MaterialDesignFloatingActionAccentButton}" /></DockPanel><ListBoxMargin="5"ItemsSource="{Binding TodoDtos}"ScrollViewer.VerticalScrollBarVisibility="Hidden"><ListBox.ItemTemplate><DataTemplate><StackPanel><TextBlock FontSize="14" Text="{Binding Title}" /><TextBlockFontSize="24"Opacity="0.5"Text="{Binding Content}" /></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></DockPanel></Grid></Grid>
</UserControl>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/8663.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【JAVA】 String 方法附件

个人主页&#xff1a;【&#x1f60a;个人主页】 系列专栏&#xff1a;【❤️初识JAVA】 文章目录 String 方法 String 方法 char charAt(int index)返回指定索引处的 char 值。int compareTo(Object o) 把这个字符串和另一个对象比较。 int compareTo(String anotherString)按…

基于Jquery EasyUI JSZip FileSaver的简单使用

一、前言 在前端的项目开发中 &#xff0c;下载文件压缩包是很重要的一个环节&#xff0c;那么怎么下载多个文件并压缩成ZIP下载呢&#xff1f; 二、使用步骤 1、引用库 <script type"text/javascript" src"~/Scripts/comm/jszip.min.js" ></…

【http长连接+池化】

参考&#xff1a; https://it.cha138.com/ios/show-49862.html http://blog.chinaunix.net/uid-16480950-id-103597.html https://www.cnblogs.com/kevin-yuan/p/13731552.html https://www.jianshu.com/p/17e9aacca438 一、http长连接和短连接 HTTP协议是无状态的协议&#…

AMEYA360报道:手机直连卫星通信发展的三个阶段

卫星通信的发展从过去、现在与规划&#xff0c;可以分为三个阶段。手机卫星通信的第一个阶段中&#xff0c;较为典型的有铱星公司、海事卫星电话、天通卫星通信等&#xff0c;终端设备方面已经可以做到手持设备直接通过自带的天线与卫星进行通信。 包括铱星、天通卫星等&#x…

C# WPF项目创建(基于VS 2019介绍)

1.打开VS&#xff0c;选择《创建新项目》 2.选择《WPF应用》&#xff0c;这里设计两个有.NET Framework框架和.NET core 框架&#xff0c;如图所示&#xff1a; 区别&#xff1a; .NET Framework 框架只能在windows下使用 .NET core 框架支持linux 下运行 3. 项目名称根据需…

深入浅出Pytorch函数——torch.unsqueeze

分类目录&#xff1a;《深入浅出Pytorch函数》总目录 相关文章&#xff1a; 深入浅出Pytorch函数——torch.squeeze 深入浅出Pytorch函数——torch.unsqueeze 返回一个新的张量&#xff0c;且在指定位置新插入了一个大小为1的维度&#xff0c;返回的张量与该张量共享相同的底…

【C++】入门 --- 缺省参数函数重载

文章目录 &#x1f96e;一、缺省参数&#x1f355;1、基本概念&#x1f355;2、缺省参数的分类&#x1f6a9;全缺省参数&#x1f6a9;半缺省参数&#x1f6a9;缺省参数实用案例 &#x1f96e;二、函数重载&#x1f355;1、函数重载概念1️⃣参数类型不同2️⃣参数个数不同3️⃣…

Canal安装部署与测试

文章目录 第一章 Canal概述1.1 简介1.2 工作原理1.2.1 MySQL主备复制原理1.2.2 canal 工作原理 1.3 重要版本更新说明1.4 多语言 第二章 Canal安装部署2.1 准备2.2 canal安装 第三章 Canal和Kafka整合测试注意事项 第一章 Canal概述 Github地址&#xff1a;https://github.com…

使用goldengate 迁移Oracle到postgresql

环境&#xff1a; --源端&#xff1a; IP&#xff1a;10.0.4.16 hostname&#xff1a;tencent Oracle数据库版本&#xff1a;12.2.0.1.0 ogg for oracle版本&#xff1a;19.1.0.0.4 SID&#xff1a;orcl --目标端&#xff1a; IP&#xff1a;10.0.4.16 hostname&#…

ES6基础知识三:对象新增了哪些扩展?

一、属性的简写 ES6中&#xff0c;当对象键名与对应值名相等的时候&#xff0c;可以进行简写 const baz {foo:foo}// 等同于 const baz {foo}方法也能够进行简写 const o {method() {return "Hello!";} };// 等同于const o {method: function() {return "…

【MATLAB绘图】

MATLAB绘图函数&#xff1a;Plot函数详解 介绍 MATLAB是一种常用的科学计算和数据可视化工具&#xff0c;它提供了强大的绘图函数&#xff0c;使用户能够创建各种类型的图表和图形。 基本语法 plot函数的基本语法如下&#xff1a; plot(x, y)其中&#xff0c;x和y是长度相…

第八次CCF计算机软件能力认证

第一题&#xff1a;最大波动 小明正在利用股票的波动程度来研究股票。 小明拿到了一只股票每天收盘时的价格&#xff0c;他想知道&#xff0c;这只股票连续几天的最大波动值是多少&#xff0c;即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少。 输入格式 输入…

OpenStack - 构建强大的云计算平台

简介 OpenStack是一个开源的云计算平台&#xff0c;它提供了一套用于构建和管理私有云和公有云的工具和服务。OpenStack的目标是提供可伸缩性、弹性和可靠性的云基础设施服务。 组件介绍 Nova&#xff08;计算服务&#xff09; Nova是OpenStack的计算服务组件&#xff0c;负…

子网划分和计网解题方法

子网的基本概念 子网是计算机网络中的一个逻辑单元&#xff0c;是由多个IP地址组成的网络。在计算机网络中&#xff0c;IP地址是一个32位的二进制数&#xff0c;用于标识网络上的设备。子网划分是将一个大型的IP地址网络划分为多个小的IP地址网络&#xff0c;每个小的IP地址网…

php-golang-rpc spiral/goridge库和php spiral/goridge2.4.5实践

golang 代码&#xff1a; package main import ( "fmt" "net" "net/rpc" "github.com/spiral/goridge/v2" ) type App struct{} func (*App) Hi(name string, r *string) error { *r fmt.Sprintf("hello %s!", name) re…

至臻画质、高清带感,这就是声网实时高清·超级画质

至臻画质、高清带感&#xff0c;这就是声网实时高清超级画质 7月26日&#xff0c;实时互动云服务商声网在北京举办“实时高清超级画质”发布会。 实时高清超级画质是声网面向实时视频场景提供的一套以提升视频画质和使用体验为核心的解决方案&#xff0c;包含至臻画质、美颜悦…

uni-app:实现账号密码登录,并且实现当页面登录过该账号在下次登录时无需再输入账号密码(本地缓存实现)

效果 前端代码 一、完整代码 <template><view><view class"all"><view class"title"><image :src"title_login" alt"图片损坏" /></view><form class"login-form" submit"fo…

TSDB - VictoriaMetrics 技术原理浅析

一、前言 在监控领域&#xff0c;通常需要指标存储组件TSDB&#xff0c;目前开源的TSDB组件比较多&#xff0c;各个组件性能、高可用性、维护成本等等各有差异。本文不分析选型问题&#xff0c;重点讲解VictoriaMetrics&#xff08;后面简称为vm&#xff09;。 有兴趣的朋友建议…

回调函数的使用

使用例子 #include<stdio.h>int Callback_1(int x) // Callback Function 1 {printf("Hello, this is Callback_1: x %d ", x);return 0; }int Callback_2(int x) // Callback Function 2 {printf("Hello, this is Callback_2: x %d ", x);return…

吉林大学计算机软件考研经验贴

文章目录 简介政治英语数学专业课 简介 本人23考研&#xff0c;一战上岸吉林大学软件工程专硕&#xff0c;政治72分&#xff0c;英一71分&#xff0c;数二144分&#xff0c;专业课967综合146分&#xff0c;总分433分&#xff0c;上图&#xff1a; 如果学弟学妹需要专业课资料…