当前位置: 首页 > news >正文

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>

相关文章:

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

首页界面 新建文件 添加文件&#xff3b;类型&#xff1a;用户控件&#xff3d; ./Common/Models/TaskBars.cs ./Common/Models/ToDoDto.cs ./Common/Models/MemoDto.cs 新建类 TaskBars.cs using System; using System.Collections.Generic; using System.Linq; using Sy…...

一文带你迅速入门SprIngMVC,看这一篇就足够了!

0. 什么是SpringMVC 要知道什么是SpringMVC&#xff0c;我们首先得知道什么 MVC&#xff0c;MVC是软件工程中的一种架构模式&#xff0c;分为 Model、View、Control。它把软件系统分为模型、视图和控制器三个基本部分。 Model&#xff1a;模型&#xff0c;应用程序负责数据逻…...

js路由跳转时放弃正在pending的请求

在单页面应用中通常会对请求进行catch处理&#xff0c;如果用户打开a页面后页面发出了一个请求去获取aaa&#xff0c;但是由于某种原因请求一直在pending。此时用户又进入了b页面&#xff0c;在浏览时a页面的请求失败了&#xff0c;然后页面弹出提示&#xff1a;“数据aaa请求失…...

LeetCode(sql)-0723

聚合函数 620 select * from cinema where mod(id,2)1 and description <> boring order by rating desc1251 select p.product_id, Round(sum(price*units)/sum(units),2)as average_price from UnitsSold u left join Prices p using(product_id) where purchase_d…...

【C++】开源:grpc远程过程调用(RPC)配置与使用

&#x1f60f;★,:.☆(&#xffe3;▽&#xffe3;)/$:.★ &#x1f60f; 这篇文章主要介绍grpc远程过程调用&#xff08;RPC&#xff09;配置与使用。 无专精则不能成&#xff0c;无涉猎则不能通。。——梁启超 欢迎来到我的博客&#xff0c;一起学习&#xff0c;共同进步。 喜…...

rabbitmq模块启动报java.net.SocketException: socket closed的解决方法

问题 最近在接手一个项目时&#xff0c;使用的是spring-cloud微服务构架&#xff0c;mq消息消费模块是单独一个模块&#xff0c;但启动这个模块一直报如下错误&#xff1a; java.net.SocketException: socket closed 这个错误是这个模块注册不到nacos报的错&#xff0c;刚开…...

uni-app 中定时器的使用

学习目标&#xff1a; 学习目标如下所示&#xff1a; uniapp中通过使用uni-app提供的定时器API来实现定时器功能。 学习内容&#xff1a; 内容如下所示&#xff1a; **uni-app的定时器API分为两种&#xff1a; 1.第一种方式&#xff1a; setTimeout函数&#xff0c;用于设置一…...

基于物联网、视频监控与AI视觉技术的智慧电厂项目智能化改造方案

一、项目背景 现阶段&#xff0c;电力行业很多企业都在部署摄像头对电力巡检现场状况进行远程监控&#xff0c;但是存在人工查看费时、疲劳、出现问题无法第一时间发现等管理弊端&#xff0c;而且安全事件主要依靠人工经验判断分析、管控&#xff0c;效率十分低下。 为解决上述…...

内网穿透远程查看内网监控摄像头

内网穿透远程查看内网监控摄像头 在现代社会中&#xff0c;大家总是奔波于家和公司之间。大部分时间用于工作中&#xff0c;也就很难及时知晓家中的动态情况&#xff0c;对于家中有老人、小孩或宠物的&#xff08;甚至对居住环境安全不放心的&#xff09;&#xff0c;这已然是…...

【Flume 01】Flume简介、部署、组件

1 Flume简介 Flume是一个高可用、高可靠、分布式的海量日志采集、聚合和传输的系统 主要特性&#xff1a; 它有一个简单、灵活的基于流的数据流结构&#xff08;使用Event封装&#xff09;具有负载均衡机制和故障转移机制一个简单可扩展的数据模型(Source、Channel、Sink) Sou…...

三款即时通讯工具推荐:J2L3x、Telegram、WhatsApp 你选哪个?

1、J2L3x J2L3x 是一款受欢迎的即时通讯工具&#xff0c;广泛应用于企业团队之间的沟通和协作。它提供了多种通讯方式&#xff0c;包括群组聊天、私人消息和文件共享等&#xff0c;还可以方便地与其他应用程序和服务集成。即使你不在工作场所&#xff0c;你也可以在任何地方使…...

C++ 单例模式(介绍+实现)

文章目录 一. 设计模式二. 单例模式三. 饿汉模式四. 懒汉模式结束语 一. 设计模式 单例模式是一种设计模式 设计模式(Design Pattern)是一套被反复使用&#xff0c;多数人知晓的&#xff0c;经过分类的&#xff0c;代码设计经验的总结。 为什么要有设计模式 就像人类历史发展会…...

uniapp项目集成本地插件

在项目根目录下创建nativeplugins文件夹 拷贝插件到目录nativeplugins 在manifest.json -> App原生插件配置 -> 本地插件里勾选插件 删除本地基座和手机app从新自定义基座运行...

MFC CList 类的使用

MFC提供CList 类&#xff1b; 类CList支持可按顺序或按值访问的非唯一对象的有序列表&#xff1b;CList 列表与双链接列表行为相似&#xff1b; 类型POSITION的变量是列表的关键字&#xff1b;可使用POSITION变量作为循环因子来顺序遍历列表&#xff0c;作为书签来保存位置&am…...

iptable防火墙

防火墙 防火墙的主要功能是隔离&#xff0c;决定数据是否可以被外网访问以及哪些数据可以进入内。 它主要部署在网络边缘或者主机边缘&#xff0c;应用在网络层。 防火墙的安全技术: 1、入侵检测系统&#xff1a;检测数威胁&#xff0c;病毒&#xff0c;木马&#xff0c;不…...

二、SQL-5.DQL-9).执行顺序

一、案例&#xff1a; 查询年龄大于15的员工的姓名、年龄&#xff0c;并根据年龄进行升序排序 select name, age from emp where age > 15 order by age asc; 先执行①from&#xff08;定义emp的别名为e&#xff09;&#xff0c;再执行②where&#xff08;调用别名e&…...

Ubuntu通用镜像加速配置

备份 cp -rf /etc/apt/sources.list /etc/apt/sources.list.bak开始配置 阿里云 sed -i shttp://archive.ubuntu.comhttps://mirrors.aliyun.comg /etc/apt/sources.listsed -i shttp://security.ubuntu.comhttps://mirrors.aliyun.comg /etc/apt/sources.list清华源 sed -i …...

Linux安装部署Nacos和sentinel

1.将nacos安装包下载到本地后上传到linux中 2.进入nacos的/bin目录,输入命令启动nacos [rootlocalhost bin]# sh startup.sh -m standalone注:使用第二种方式启动,同时增加日志记录的功能 2.2 startup.sh文件是不具备足够的权限,否则不能操作 给文件赋予执行权限 [rootlocalh…...

Vue3+ElementPlus+TS实现右上角消息数量实时更新

Vue3ElementPlusTS实现右上角消息数量实时更新 背景 项目需求&#xff0c;前端右上角铃铛图标 显示接收到的消息通知&#xff0c;并且显示消息数量以及实时更新。&#xff08;一般是点击操作按钮后增加一条消息通知&#xff0c;图标上的数字也随之更新&#xff09; 【原来的想…...

去除重复字母(力扣)贪心 + 队列 JAVA

给你一个字符串 s &#xff0c;请你去除字符串中重复的字母&#xff0c;使得每个字母只出现一次。需保证 返回结果的字典序最小&#xff08;要求不能打乱其他字符的相对位置&#xff09;。 示例 1&#xff1a; 输入&#xff1a;s “bcabc” 输出&#xff1a;“abc” 示例 2&am…...

练习(含atoi的模拟实现,自定义类型等练习)

一、结构体大小的计算及位段 &#xff08;结构体大小计算及位段 详解请看&#xff1a;自定义类型&#xff1a;结构体进阶-CSDN博客&#xff09; 1.在32位系统环境&#xff0c;编译选项为4字节对齐&#xff0c;那么sizeof(A)和sizeof(B)是多少&#xff1f; #pragma pack(4)st…...

Python:操作 Excel 折叠

💖亲爱的技术爱好者们,热烈欢迎来到 Kant2048 的博客!我是 Thomas Kant,很开心能在CSDN上与你们相遇~💖 本博客的精华专栏: 【自动化测试】 【测试经验】 【人工智能】 【Python】 Python 操作 Excel 系列 读取单元格数据按行写入设置行高和列宽自动调整行高和列宽水平…...

在rocky linux 9.5上在线安装 docker

前面是指南&#xff0c;后面是日志 sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo sudo dnf install docker-ce docker-ce-cli containerd.io -y docker version sudo systemctl start docker sudo systemctl status docker …...

ABAP设计模式之---“简单设计原则(Simple Design)”

“Simple Design”&#xff08;简单设计&#xff09;是软件开发中的一个重要理念&#xff0c;倡导以最简单的方式实现软件功能&#xff0c;以确保代码清晰易懂、易维护&#xff0c;并在项目需求变化时能够快速适应。 其核心目标是避免复杂和过度设计&#xff0c;遵循“让事情保…...

iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈

在日常iOS开发过程中&#xff0c;性能问题往往是最令人头疼的一类Bug。尤其是在App上线前的压测阶段或是处理用户反馈的高发期&#xff0c;开发者往往需要面对卡顿、崩溃、能耗异常、日志混乱等一系列问题。这些问题表面上看似偶发&#xff0c;但背后往往隐藏着系统资源调度不当…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)

前言&#xff1a; 双亲委派机制对于面试这块来说非常重要&#xff0c;在实际开发中也是经常遇见需要打破双亲委派的需求&#xff0c;今天我们一起来探索一下什么是双亲委派机制&#xff0c;在此之前我们先介绍一下类的加载器。 目录 ​编辑 前言&#xff1a; 类加载器 1. …...

Oracle11g安装包

Oracle 11g安装包 适用于windows系统&#xff0c;64位 下载路径 oracle 11g 安装包...

【无标题】湖北理元理律师事务所:债务优化中的生活保障与法律平衡之道

文/法律实务观察组 在债务重组领域&#xff0c;专业机构的核心价值不仅在于减轻债务数字&#xff0c;更在于帮助债务人在履行义务的同时维持基本生活尊严。湖北理元理律师事务所的服务实践表明&#xff0c;合法债务优化需同步实现三重平衡&#xff1a; 法律刚性&#xff08;债…...

前端调试HTTP状态码

1xx&#xff08;信息类状态码&#xff09; 这类状态码表示临时响应&#xff0c;需要客户端继续处理请求。 100 Continue 服务器已收到请求的初始部分&#xff0c;客户端应继续发送剩余部分。 2xx&#xff08;成功类状态码&#xff09; 表示请求已成功被服务器接收、理解并处…...