当前位置: 首页 > 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…...

谷歌浏览器插件

项目中有时候会用到插件 sync-cookie-extension1.0.0&#xff1a;开发环境同步测试 cookie 至 localhost&#xff0c;便于本地请求服务携带 cookie 参考地址&#xff1a;https://juejin.cn/post/7139354571712757767 里面有源码下载下来&#xff0c;加在到扩展即可使用FeHelp…...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

微软PowerBI考试 PL300-选择 Power BI 模型框架【附练习数据】

微软PowerBI考试 PL300-选择 Power BI 模型框架 20 多年来&#xff0c;Microsoft 持续对企业商业智能 (BI) 进行大量投资。 Azure Analysis Services (AAS) 和 SQL Server Analysis Services (SSAS) 基于无数企业使用的成熟的 BI 数据建模技术。 同样的技术也是 Power BI 数据…...

MySQL 隔离级别:脏读、幻读及不可重复读的原理与示例

一、MySQL 隔离级别 MySQL 提供了四种隔离级别,用于控制事务之间的并发访问以及数据的可见性,不同隔离级别对脏读、幻读、不可重复读这几种并发数据问题有着不同的处理方式,具体如下: 隔离级别脏读不可重复读幻读性能特点及锁机制读未提交(READ UNCOMMITTED)允许出现允许…...

1688商品列表API与其他数据源的对接思路

将1688商品列表API与其他数据源对接时&#xff0c;需结合业务场景设计数据流转链路&#xff0c;重点关注数据格式兼容性、接口调用频率控制及数据一致性维护。以下是具体对接思路及关键技术点&#xff1a; 一、核心对接场景与目标 商品数据同步 场景&#xff1a;将1688商品信息…...

汽车生产虚拟实训中的技能提升与生产优化​

在制造业蓬勃发展的大背景下&#xff0c;虚拟教学实训宛如一颗璀璨的新星&#xff0c;正发挥着不可或缺且日益凸显的关键作用&#xff0c;源源不断地为企业的稳健前行与创新发展注入磅礴强大的动力。就以汽车制造企业这一极具代表性的行业主体为例&#xff0c;汽车生产线上各类…...

高等数学(下)题型笔记(八)空间解析几何与向量代数

目录 0 前言 1 向量的点乘 1.1 基本公式 1.2 例题 2 向量的叉乘 2.1 基础知识 2.2 例题 3 空间平面方程 3.1 基础知识 3.2 例题 4 空间直线方程 4.1 基础知识 4.2 例题 5 旋转曲面及其方程 5.1 基础知识 5.2 例题 6 空间曲面的法线与切平面 6.1 基础知识 6.2…...

Spring数据访问模块设计

前面我们已经完成了IoC和web模块的设计&#xff0c;聪明的码友立马就知道了&#xff0c;该到数据访问模块了&#xff0c;要不就这俩玩个6啊&#xff0c;查库势在必行&#xff0c;至此&#xff0c;它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据&#xff08;数据库、No…...

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

虚拟电厂发展三大趋势:市场化、技术主导、车网互联

市场化&#xff1a;从政策驱动到多元盈利 政策全面赋能 2025年4月&#xff0c;国家发改委、能源局发布《关于加快推进虚拟电厂发展的指导意见》&#xff0c;首次明确虚拟电厂为“独立市场主体”&#xff0c;提出硬性目标&#xff1a;2027年全国调节能力≥2000万千瓦&#xff0…...