惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
D
Docker
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
罗磊的独立博客
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
C
Check Point Blog
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Proofpoint News Feed
L
LangChain Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
有赞技术团队
有赞技术团队
腾讯CDC
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - Franky
量子位

博客园 - uxinxin

.NET10 中配置Swagger的记录 .NET10中通过appsettings.json配置文件获取信息的几个方法 学习使用Taurus的微服务群在.NET Framework4.8环境下的搭建 .net framework 中Owin 通过启动类 Startup.cs 使用 SignalR B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【八】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【七】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【六】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【五】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【四】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【三】 B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习记录 【二】 .NET程序屏蔽一些无效蜘蛛的访问配置 asp.net 动态加载与卸载程序集的尝试(没有成功)欢迎解决的朋友留言告知 Framework 4.6.2下的SignalR使用,以及WPF下同步使用 react 16.8.4版本中的生命周期中的细节 在组件挂在时使用了定时器的处理——尚硅谷React教程(2022加更,B站超火react教程)学习笔记 CYQ.Data的XML操作的一些自己使用记录 IIS URL Rewrite将伪静态配置文件放在web.config外部 ASP.NET Core EF MVC 登录验证 一步步教你用html+div+css+js基于Jquery实现一套数字华容道游戏
B站朝夕教育 【.NET9.0+WPF实战三类流程化业务逻辑控制】学习...
uxinxin · 2024-12-04 · via 博客园 - uxinxin

播放地址:20241120-.NET9.0+WPF实战三类流程化业务逻辑控制-10_哔哩哔哩_bilibili

Nuget需要安装两个依赖

CommunityToolkit.Mvvm

Microsoft.Xaml.Behaviors.Wpf

第1-2课时主要是理论,略

第3课时,WPF中新增的主题设置

修改MainWindow.xaml文件中的代码为:

 1 <Window x:Class="WpfApp1.Views.MainWindow"
 2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6         xmlns:local="clr-namespace:WpfApp1"
 7         mc:Ignorable="d"
 8         Title="MainWindow" Height="450" Width="800" Background="White">
 9     <ScrollViewer>
10     <Grid>
11         <TabControl>
12             <TabItem Header="AAAA">
13                 <StackPanel>
14                     <Button Content="Button" />
15                     <Label Content="Label" />
16                     <CheckBox Content="CheckBox" />
17                     <RadioButton Content="RadioButton" />
18                     <ToggleButton Content="ToggleButton" />
19                     <ComboBox>
20                         <ComboBoxItem Content="AAA" />
21                         <ComboBoxItem Content="BBB" />
22                         <ComboBoxItem Content="CCC" />
23                         <ComboBoxItem Content="DDD" />
24                     </ComboBox>
25                     <ListBox>
26                         <ListBoxItem Content="AAAA" />
27                         <ListBoxItem Content="AAAA" />
28                         <ListBoxItem Content="AAAA" />
29                         <ListBoxItem Content="AAAA" />
30                         <ListBoxItem Content="AAAA" />
31                     </ListBox>
32                     <Calendar />
33                     <DatePicker />
34                 </StackPanel>
35             </TabItem>
36             <TabItem Header="BBB">
37 
38             </TabItem>
39             <TabItem Header="CCC">
40 
41             </TabItem>
42         </TabControl>
43 
44         </Grid>
45     </ScrollViewer>
46 </Window>

演示主题使用的代码

在App.xaml文件中修改代码

增加 ResourceDictionary节点,及内容,内部包含多种不同风格,可以自己尝试切换

 1 <Application x:Class="WpfApp1.App"
 2              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4              xmlns:local="clr-namespace:WpfApp1"
 5              StartupUri="Views/MainView.xaml">
 6     <Application.Resources>
 7         <ResourceDictionary>
 8             <ResourceDictionary.MergedDictionaries>
 9                 <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
10                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Aero;component/Themes/Aero.NormalColor.xaml" />-->
11                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.AeroLite;component/Themes/AeroLite.NormalColor.xaml" />-->
12                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Classic;component/Themes/Classic.xaml" />-->
13                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Luna;component/Themes/Luna.HomeStead.xaml" />-->
14                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Luna;component/Themes/Luna.Metallic.xaml" />-->
15                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Luna;component/Themes/Luna.NormalColor.xaml" />-->
16                 <!--<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Royale;component/Themes/Royale.NormalColor.xaml" />-->
17             </ResourceDictionary.MergedDictionaries>
18         </ResourceDictionary>
19     </Application.Resources>
20 </Application>

WPF切换主题

第4-5课时创建MainView.xaml窗口演示如何使用传统方法实现拖拽控件

  • 在窗口Window节点中设置属性WindowStartupLocation="CenterScreen",让窗口启动时在屏幕中间位置
  • 注意如果你的VS主题设置的是深色需要再再Window节点上增加Background="White"或者其他颜色,否则启动后背景黑色应用了上面的主题后很多效果看不到
  • xaml文件代码
     1 <Window x:Class="WpfApp1.MainView"
     2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     6         xmlns:local="clr-namespace:WpfApp1"
     7         mc:Ignorable="d"
     8         WindowStartupLocation="CenterScreen"
     9         Background="White"
    10         Title="MainView" Height="650" Width="1300">
    11     <Grid>
    12         <Grid.ColumnDefinitions>
    13             <ColumnDefinition Width="200" />
    14             <ColumnDefinition Width="300" />
    15             <ColumnDefinition />           
    16         </Grid.ColumnDefinitions>
    17         <ListView>
    18             <ListViewItem Content="AAA" PreviewMouseLeftButtonDown="ListViewItem_MouseLeftButtonDown"></ListViewItem>
    19             <ListViewItem Content="BBB" PreviewMouseLeftButtonDown="ListViewItem_MouseLeftButtonDown"></ListViewItem>
    20             <ListViewItem Content="CCC" PreviewMouseLeftButtonDown="ListViewItem_MouseLeftButtonDown"></ListViewItem>
    21             <ListViewItem Content="DDD" PreviewMouseLeftButtonDown="ListViewItem_MouseLeftButtonDown"></ListViewItem>
    22         </ListView>
    23         <ListBox Grid.Column="1" Drop="ListBox_Drop" AllowDrop="True"></ListBox>
    24     </Grid>
    25 </Window>
  • MainView.xaml.cs文件里新增代码
     1         private void ListViewItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     2         {
     3             DragDrop.DoDragDrop((DependencyObject)sender, (sender as ListViewItem).Content, DragDropEffects.Copy);
     4         }
     5 
     6         private void ListBox_Drop(object sender, DragEventArgs e)
     7         {
     8             string value = e.Data.GetData(typeof(string)).ToString();
     9             (sender as ListBox).Items.Add(new ListBoxItem() { Content=value});
    10         }