系列文章目录
WPF学习1. 经验总结
- 系列文章目录
- 前言
-
- git 项目提交
- wpf理论
- 理论的链接
- 控件介绍
前言
下面的几个就足够熟悉了。好好学习,落到实处。
查看以下的地址就好了。
参考链接
学习参考
官方文档 |
参考项目 |
11 |
我的Blog Wpf |
画图工具 |
动画11-22 |
官网组件的查看 |
流程图11–22 |
温度区域测量 |
官方文档 |
思维导图 |
|
wpf教程 |
MVVM框架 |
UI控件 |
WPF Tutorial |
Prism-文档 |
HandyControl-11 |
|
|
|
WPF从零到1教程详解 |
CommunityToolkit.Mvvm |
MaterialDesignInXAML |
|
|
|
B站痕迹-git-MyToDoApp |
Caliburn.Micro官网-git |
11-22-33-44-55-66-77-88 |
|
|
|
cnblog系列文章 |
MVVMLight官网-好文 |
|
|
|
|
项目案例 |
CM11-22-33 |
|
|
|
|
111-222-333 |
CTM11-22-33-44 |
|
|
|
|
wpf模板-11-22 |
PRhyui-Smp-11-22 |
|
|
|
|
TerminalMACS |
|
|
|
|
|
dotnet9 |
|
|
随记好文 |
|
WPF使用转换器(Converter) |
控件共用事件 |
自定义控件 极力推荐 |
gitHubTopicwpf |
千自学 |
|
码客 |
|
独立观察员 |
|
git 项目提交
1. 在git或gitee 上建一个项目,克隆到本地上.
2. 将代码 copy 到 本地的文件夹src下面来
3. git add .
4. git commit -m "输入此次提交的解释"
5. git push origin master
git pull
git status
git reset --hard commit_id。
git diff <文件>
git reflog
git branch -a
git branch zy
git checkout zy
git checkout -b zy(分支名)
git help <command>
git log
git clone
git config --global user.name "bettyaner"
git config --global user.email bettyaner@163.com
- git中有两个状态:内容状态和文件状态,
内容状态标示内容文件的改变,有三个区域:工作目录,暂存区和提交区
文件状态有两个状态:已跟踪和未跟踪
wpf理论
布局、控件、样式、依赖属性、资源、触发器、模板、数据绑定mvvm command
(prism ,MVVMLight ,CommunityToolkit.Mvvm,Microsoft.Toolkit.Mvvm ,Caliburn.Micro(简称CM)) --fody
StackPanel,WrapPanel,DockPanel,Grid,UniformGrid,Canvas
Trigger 、MultiTrigger、DataTrigger、 MultiDataTrigger、 EventTrigger
每个触发器都是 System.Windows.TriggerBase的派生类实例,
Default、OneTime、OneWay、TwoWay、OneWayToSource
Resources>Style(key,TargetType,BasedOn)>Setter
StaticResource,DynamicResource
<SolidColorBrush x:Key="solidColor" Color="Red"/>
this.Resources["solidColor"]=new SolidColorBrush(Colors.Yellow);
<Line Height="15" Y2="1" Stroke="#707070" Stretch="Uniform" Margin="6 0" />
new SolidColorBrush( Color.FromArgb(255, 255, 0, 0));
new SolidColorBrush((Color)ColorConverter.ConvertFromString("#92e492"));
new SolidColorBrush(Color.FromRgb(255,255,255));
Brushes.Green;
VerticalScrollBarVisibility HorizontalScrollBarVisibility CanContentScroll="True"
<TextBox Height="373" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"></TextBox>
Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/DrawTools;component/Images/file.ico")).Stream;
treeViewItem.Icon = new System.Drawing.Icon(iconStream);
Image image = new Image(); image.Width = 850; image.Stretch = Stretch.Fill;
BitmapImage picture = new BitmapImage(new Uri(lbi));
image.Source = picture;
<Button Name="btnDefault" IsDefault="true" Click="OnClickDefault">OK</Button>设置回车
<Button Name="btnDefault" IsCancel="true" Click="OnClickDefault">OK</Button>设置ESC
Nuget包:Microsoft.Xaml.Interactions
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding Btncommand}" CommandParameter="read" />
</i:EventTrigger>
</i:Interaction.Triggers>
pack://application:,,,/是协议;“,,,”是“
Uri uri = new Uri("pack://application:,,,/ResourceFile.xaml", UriKind.Absolute);
<Button Content="ClickMe" Click="OnClick1" ClickMode="Hover"/>
void OnClick1(object sender, RoutedEventArgs e)=> btn1.Background = Brushes.LightBlue;
1.代码摘抄
public static class Win32Helper
{
[DllImport("shell32.dll")]
public static extern int ShellAbout(IntPtr hWnd, string szApp, string szOtherStuff, IntPtr hIcon);
}
private void OnAboutCommand()
{
Assembly assembly = Assembly.GetExecutingAssembly();
var title = assembly.GetCustomAttribute(typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
var version = assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute)) as AssemblyFileVersionAttribute;
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("WpfNotepad.ico", UriKind.Relative));
Icon icon = new Icon(streamResourceInfo.Stream);
Win32Helper.ShellAbout(Process.GetCurrentProcess().MainWindowHandle, title.Title, version.Version, icon.Handle);
}
private void OnFeedBackCommand()
{
Process.Start("feedback-hub://?appid=1231313");
}
private void OnHelpCommand()
{
Process.Start("https://go.microsoft.com/fwlink/?LinkId=834783");
}
# C#之AOP的实现
1.什么是AOP
AOP(Aspect Oriented Programming)的字面意思是“面向切面编程”。举个例子解释一下,如果我们把三层架构的表现层,业务逻辑层和数据访问层看作是河流的上游,中游和下游,那么“面向切面编程”就是架设在上游和中游分界处的三峡大坝,他对每一滴河水作一个公共的操作,比如染成红色或者过滤掉大鱼。
AOP的意义在于能够让我们在不影响原有功能的前提下,为软件横向扩展功能,说穿了就是解耦。
https://www.cnblogs.com/panpanwelcome/p/8617552.html
2. 任务调度:
这个任务每天或每周自动执行,定时刷新数据。
Coravel、Quart.Net、HangFire.
3. WPF中怎样拖拽文件呢?
注册这两个事件即可:DragEnter、Drop
<Grid AllowDrop="True" Drop="Grid_Drop" DragEnter="Grid_DragEnter">
private void Grid_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effects = DragDropEffects.Link;
else
e.Effects = DragDropEffects.None;
}
private void Grid_Drop(object sender, DragEventArgs e)
{
var fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
zhouyi.Content = fileName;
}
4. c#中类的执行顺序
1子类静态成员2子类静态构造3子类实例成员4父类静态成员
5父类静态构造6父类实例成员7父类实例构造8子类实例构造
5. goto 控制程序跳转到指定的位置执行
提示:goto 语句并不限于在循环中使用,其它的情况也可以使用。但是,goto 语句不能从循环外跳转到循环语句中,而且不能跳出类的范围。
login:
Console.WriteLine("请输入密码");var userpwd = Console.ReadLine();
goto login;
6. C#中ref、out、in的区别与使用
ref、out、in都是将参数按引用来传递,什么都不加是值传递,这在内存分配上是有差异的。
ref:可读可写(可进可出)
out:只能写不能读(只出不进)
in:只能读不能写(只进不出)
7. 值传递、引用传递、输出传递(值传递是将参数传递给函数的默认方式)
值传递:值传递的本质就是将实参的副本(将实参的值复制一份)传递给函数的形参。认方式
引用传递:引用传递是对变量内存位置的引用。
8. C# 中的析构函数
同样是类中的一个特殊成员函数,主要用于在垃圾回收器回收类实例时执行一些必要的清理操作。
class Car
{
~Car()
Console.WriteLine("类中的析构函数");
}
9. 使用 this 关键字串联构造函数
Test test = new Test("测试数据");
public class Test
{
public Test(){ Console.WriteLine("无参构造函数");}
public Test(string text) : this()
{Console.WriteLine(text+"实例构造函数");}
}
10. this关键字(niubi)
1) 使用 this 表示当前类的对象
2) 使用 this 关键字串联构造函数
3) 使用 this 关键字作为类的索引器
4) 使用 this 关键字作为原始类型的扩展方法
11. 通过委托传值,触发,值得参考。
public class PublisherDemo
{
private string myVar;
public static Action<string> ChangeValue;
public string MyVar
{
get => myVar;
set { myVar = value; ChangeValue(value); }
}
}
public class SubscriberDemo
{
public SubscriberDemo()
PublisherDemo.ChangeValue+=(obj)=>{};
}
12. *.Parse(string)、 *.TryParse(string,out int demo)
注意:ConvertToInt32()和int.Parse()对于空值(null)的处理不同,ConvertToInt32(null)会返回0而不会产生任何异常,但int.Parse(null)则会产生异常。
Console.WriteLine(Int32.Parse("22"));
Int32.TryParse("33", out int demo);
Convert.ToInt32(null)
13.
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
14. FlowDocumentReader滚动到顶部
FlowDocumentPageViewer1.Document.BringIntoView();
15.
这似乎很适合页面浏览,但不适用于滚动视图,这没关系。
reader的类型是FlowDocumentReader,文档是其中的FlowDocument。
设置的书签:
var paginator = ((IDocumentPaginatorSource)document).DocumentPaginator as DynamicDocumentPaginator;
var position = paginator.GetPagePosition(paginator.GetPage(reader.PageNumber - 1)) as TextPointer;
bookmark = position.Paragraph;
还原书签:
bookmark.BringIntoView();
理论的链接
16. WPF使用阿里巴巴iconfont矢量图标库
http://t.zoukankan.com/Stay627-p-14469662.html
17. 读取appsetting.json的两种方式
https://www.modb.pro/db/104729
18. WPF模拟点击按钮
btn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, btn));
19. 关于c#:将List < T >转换为ObservableCollection < T >
https://www.codenong.com/16432450/
20. 《.NET/C#面试手册》
https://www.yuque.com/zhanglin-l1ak6/ll06t7
21. 中国有哪些比较出名的C#大佬。?
https://www.cnblogs.com/sexintercourse/p/16256753.html
22. ECMAScript 6 入门
https://es6.ruanyifeng.com/#docs/object-methods
23. .Net Core Excel导入导出神器Npoi.Mapper
https://www.cnblogs.com/wucy/p/14125392.html
https://donnytian.github.io/Npoi.Mapper/
24. MiniExcel
https://gitee.com/dotnetchina/MiniExcel#getstart1
25. c# 获取照片的经纬度和时间
https://blog.csdn.net/fangyu723/article/details/102820203
控件介绍
- (基本)Border 、TextBlock、TextBox 、RichTextBox 、PasswordBox
- (按钮)Button 、RadioButton 、RepeatButton
- (布局)Grid、DockPanel、StackPanel、WrapPanel、Panel
- (数据显示)DataGrid、ListView、TreeView
- (菜单)ContextMenu、Menu、ToolBar
- (日期)Calendar、DatePicker
- (导航) Frame、Hyperlink、Page、NavigationWindow、TabControl
- Frame 框架是一种支持导航的内容控件。
- Hyperlink 提供用于在流内容中承载超链接的功能的内联级别的流内容元素。
- Page 封装一页可由 Windows Internet Explorer、NavigationWindow 和 Frame 导航到和承载的内容
- NavigationWindow 表示支持内容导航的窗口。
- TabControl 表示包含多个项的控件,这些项共享屏幕上的同一空间。
- Calendar 代表一个控件,此控件允许用户使用可视的日历显示来选择日期。
- DatePicker 表示一个允许用户选择日期的控件
- ContextMenu 表示一个弹出菜单,该弹出菜单使控件能够公开特定于该控件的上下文的功能。
- Menu 表示一个 Windows 菜单控件,该控件可用于按层次组织与命令和事件处理程序关联的元素。
- ToolBar 为一组命令或控件提供容器。
- DataGrid 表示用于在可自定义的网格中显示数据的控件
- ListView 表示用于显示数据项列表的控件
- TreeView 表示一个控件,该控件在树结构(其中的项可以展开和折叠)中显示分层数据。
- Grid 定义由列和行组成的灵活的网格区域
- DockPanel 定义一个区域,从中可以按相对位置水平或垂直排列各个子元素
- StackPanel 将子元素排列成水平或垂直的一行
- WrapPanel 按从左到右的顺序位置定位子元素,在包含框的边缘处将内容切换到下一行
- Panel 为所有 Panel 元素提供基类
- Border 在另一个元素四周绘制边框和/或背景。
- TextBox 表示一个控件,该控件可用于显示或编辑无格式文本。
- RichTextBox 支持更丰富内容
- PasswordBox有关需要接受密码或其他敏感输入
- RepeatButton表示从按下按钮到释放按钮的时间内重复引发其 Click 事件的控件