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

CH07_数据绑定

第7章:数据绑定

本章目标

  • 理解路由事件

  • 掌握键盘输入事件

  • 掌握鼠标输入事件

  • 掌握多点触控输入事件

数据绑定概述

什么是数据绑定

​ 将WPF中的至少一个带有依赖项属性的两个对象的两个属性进行绑定,使某一个依赖项属性可以更新和它绑定的属性的功能。

​ 数据绑定涉及两个方面:一个是绑定源,再一个是绑定目标。绑定源即空间绑定所使用的源数据,绑定目标即数据显示的控件。

对于绑定源,在WPF中可以是以下4种

  • CLR对象:可以绑定到CLR类的公开属性/子属性/索引器上
  • ADO.net 对象:例如DataTable/DataView 等。
  • XML文件:使用XPath 进行解析
  • DependencyObject: 绑定到依赖项属性上,即控件绑定控件。

对于绑定目标,必须是WPF中的DependencyObject,将数据绑定到其依赖项属性上

在这里插入图片描述

数据绑定的绑定源

  • 使用接口 INoitfyPropertyChanged
  • 使用依赖属性 DependecyProperty

数据绑定的语法

{Binding ElementName=元素名,Path=属性,Mode=绑定模式}

绑定DependencyObject对象

根据元素名称绑定

在这里插入图片描述

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel><TextBox x:Name="txt1" TextWrapping="Wrap" Height="100"></TextBox><TextBlock Text="{Binding ElementName=txt1,Path=Text}"></TextBlock></StackPanel></Window>

相对于自身或父元素绑定

在这里插入图片描述

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel Height="150"><Button Height="40" Content="{Binding RelativeSource={RelativeSource Mode=Self},Path=Height}" /><Button Height="40" Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel},Path=Height}"/></StackPanel></Window>

绑定CLR对象

绑定到单个对象

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Name="mainWindow"Title="MainWindow" Height="450" Width="800"><StackPanel><Label HorizontalAlignment="Center" FontSize="20">学生信息</Label><Grid><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="200"/><ColumnDefinition/></Grid.ColumnDefinitions><Label Grid.Row="0" Grid.Column="0" Content="名字" HorizontalAlignment='Right'/><TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name}" /><Label Grid.Row="1" Grid.Column="0" Content="性别" HorizontalAlignment='Right'/><TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Sex}" /><Label Grid.Row="2" Grid.Column="0" Content="年龄" HorizontalAlignment='Right'/><TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Age}" /></Grid></StackPanel>
</Window>

cs:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();//初始化数据Student student = new Student() { Name = "孙悟空", Sex = "男", Age = 18 };//指定数据上下文this.DataContext = student;}}/// <summary>/// 学生类/// </summary>public class Student{public string Name { get; set; }public string Sex { get; set; }public int Age { get; set; }}
}

绑定到集合元素-1

在这里插入图片描述

xaml代码:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel><TextBlock>姓名:</TextBlock><ListBox ItemsSource="{Binding NameList}"></ListBox></StackPanel></Window>

cs代码:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();//初始化数据this.NameList = new ObservableCollection<string>();this.NameList.Add("孙悟空");this.NameList.Add("猪八戒");this.NameList.Add("沙悟净");//指定数据上下文this.DataContext = this;}/// <summary>/// 姓名集合/// </summary>public ObservableCollection<string> NameList { get; set; }}
}

绑定到集合元素-2

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel><TextBlock>学生:</TextBlock><ListBox ItemsSource="{Binding StuList}"><ListBox.ItemTemplate><DataTemplate><UniformGrid Columns="3"><TextBlock Text="{Binding Name}" Margin="5"/><TextBlock Text="{Binding Sex}" Margin="5"/><TextBlock Text="{Binding Age}" Margin="5"/></UniformGrid></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel></Window>

cs:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();//初始化数据this.StuList = new ObservableCollection<Student>();this.StuList.Add(new Student {  Name="孙悟空",Sex="男",Age=150});this.StuList.Add(new Student { Name = "猪八戒", Sex = "男", Age = 120 });this.StuList.Add(new Student { Name = "沙悟净", Sex = "男", Age = 100 });//指定数据上下文this.DataContext = this;}/// <summary>/// 姓名集合/// </summary>public ObservableCollection<Student> StuList { get; set; }}/// <summary>/// 学生类/// </summary>public class Student{/// <summary>/// 姓名/// </summary>public string Name { get; set; }/// <summary>/// 性别/// </summary>public string Sex { get; set; }/// <summary>/// 年龄/// </summary>public int Age { get; set; }}
}

MVVM模式实现数据绑定

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel><TextBlock Text="{Binding School}" /><TextBlock Text="{Binding TeacherCount}" /><TextBlock Text="{Binding StudentCount}" /></StackPanel>
</Window>

cs:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();//初始化数据MainViewModel mvm = new MainViewModel();mvm.School = "广创";mvm.TeacherCount = 20;mvm.StudentCount = 500;//指定数据上下文this.DataContext = mvm;}}/// <summary>/// 页面视图 数据 模型/// </summary>public class MainViewModel{/// <summary>/// 学校/// </summary>public string School { get; set; }/// <summary>/// 教师人数/// </summary>public int TeacherCount { get; set; }/// <summary>/// 学生人数/// </summary>public int StudentCount { get; set; }}
}

属性改变通知进行数据绑定

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Name="mainWindow"Title="MainWindow" Height="450" Width="800"><StackPanel><Label HorizontalAlignment="Center" FontSize="20">学生信息</Label><Grid><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="200"/><ColumnDefinition/></Grid.ColumnDefinitions><Label Grid.Row="0" Grid.Column="0" Content="名字" HorizontalAlignment='Right'/><TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name}" /><Label Grid.Row="1" Grid.Column="0" Content="性别" HorizontalAlignment='Right'/><TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Sex}" /><Label Grid.Row="2" Grid.Column="0" Content="年龄" HorizontalAlignment='Right'/><TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Age}" /><Button Name="btn1" Grid.Row="3" Grid.Column="1" Width="120" Height="40" Margin="5" Click="btn1_Click">显示对象信息</Button><Button Name="btn2" Grid.Row="4" Grid.Column="1" Width="120" Height="40" Margin="5" Click="btn2_Click">清除对象信息</Button></Grid></StackPanel>
</Window>

cs:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{Student student;public MainWindow(){InitializeComponent();//初始化数据student = new Student() { Name = "孙悟空", Sex = "男", Age = 18 };//指定数据上下文this.DataContext = student;}/// <summary>/// 显示对象信息/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btn1_Click(object sender, RoutedEventArgs e){MessageBox.Show(this.student.ToString());}/// <summary>/// 清空对象内容/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btn2_Click(object sender, RoutedEventArgs e){this.student.Name = null;this.student.Sex = null;this.student.Age = null;}}/// <summary>/// 页面视图 数据 模型/// </summary>public class Student : INotifyPropertyChanged{private string name;public string Name{get { return name; }set{name = value;OnPropertyChanged("Name");//引发事件}}private string sex;public string Sex{get { return sex; }set{sex = value;OnPropertyChanged("Sex");//引发事件}}private int? age;public int? Age{get { return age; }set{age = value;OnPropertyChanged("Age");//引发事件}}/// <summary>/// 属性改变事件/// </summary>public event PropertyChangedEventHandler PropertyChanged;/// <summary>/// 事件处理函数/// </summary>/// <param name="property"></param>public void OnPropertyChanged(string property){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));}public override string ToString(){return string.Format("姓名:{0},性别:{1},年龄:{2}", Name, Sex, Age);}}
}

绑定ADO.NET 对象

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Name="mainWindow"Title="MainWindow" Height="450" Width="800"><StackPanel><TextBlock>学生:</TextBlock><ListBox ItemsSource="{Binding StuListData}"><ListBox.ItemTemplate><DataTemplate><UniformGrid Columns="3"><TextBlock Text="{Binding Name}" Margin="5"/><TextBlock Text="{Binding Sex}" Margin="5"/><TextBlock Text="{Binding Age}" Margin="5"/></UniformGrid></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel>
</Window>

cs:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_CH07_Demo01
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();//初始化数据this.InitialData();//指定数据上下文this.DataContext = this;}/// <summary>/// 初始化数据/// </summary>public void InitialData(){this.StuListData = new DataTable();//列this.StuListData.Columns.Add("Name", typeof(string));this.StuListData.Columns.Add("Sex", typeof(string));this.StuListData.Columns.Add("Age", typeof(int));//行DataRow row1 = this.StuListData.NewRow();row1["Name"] = "孙悟空";row1["Sex"] = "男";row1["Age"] = 18;DataRow row2 = this.StuListData.NewRow();row2["Name"] = "猪八戒";row2["Sex"] = "男";row2["Age"] = 19;DataRow row3 = this.StuListData.NewRow();row3["Name"] = "沙悟净";row3["Sex"] = "男";row3["Age"] = 20;//添加到数据表this.StuListData.Rows.Add(row1);this.StuListData.Rows.Add(row2);this.StuListData.Rows.Add(row3);}/// <summary>/// 学生数据表/// </summary>public DataTable StuListData { get; set; }}}

绑定XML对象

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Name="mainWindow"Title="MainWindow" Height="450" Width="800"><StackPanel><ListBox ItemsSource="{Binding Source={StaticResource PeopleData}}"><ListBox.ItemTemplate><DataTemplate><UniformGrid Columns="2"><TextBlock Width="200" Text="{Binding XPath='@Name'}"/><TextBlock Width="200" Text="{Binding XPath='@Age'}"/></UniformGrid></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel>
</Window>

xml:

<?xml version="1.0" encoding="utf-8" ?>
<People><Person Name="孙悟空" Age="30" /><Person Name="猪八戒" Age="25" /><Person Name="沙悟净" Age="35" />
</People>

App.xaml:

<Application x:Class="WPF_CH07_Demo01.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:WPF_CH07_Demo01"StartupUri="MainWindow.xaml"><Application.Resources><XmlDataProvider x:Key="PeopleData"  XPath="People/Person" Source="data.xml"/></Application.Resources>
</Application>

WPF的5种绑定模式

  1. OneWay(源变就更新目标属性)
  2. TwoWay(源变就更新目标并且目标变就更新源)
  3. OneTime(只根据源来设置目标,以后都不会变)
  4. OneWayToSource(与OneWay相反)
  5. Default(可以单向或双向,是靠被值定的源或目标是否有get或set来指定的)

在这里插入图片描述

xaml:

<Window x:Class="WPF_CH07_Demo01.MainWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_CH07_Demo01"mc:Ignorable="d"Name="MainWindow1"Title="MainWindow" Height="450" Width="800"><StackPanel><Slider Name="sb1" Minimum="0" Maximum="100" Value="50" Width="300" Height=" 30" SmallChange="1"/><Grid><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="300"/><ColumnDefinition/></Grid.ColumnDefinitions><Label Grid.Row="0" Grid.Column="0" Content="OneWay"/><TextBox Grid.Row="0" Grid.Column="1" Text="{Binding ElementName=sb1,Path=Value,Mode=OneWay}"/><Label Grid.Row="1" Grid.Column="0" Content="OneWayToSource"/><TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=sb1,Path=Value,Mode=OneWayToSource}"/><Label Grid.Row="2" Grid.Column="0" Content="TwoWay"/><TextBox Grid.Row="2" Grid.Column="1" Text="{Binding ElementName=sb1,Path=Value,Mode=TwoWay}"/><Label Grid.Row="3" Grid.Column="0" Content="OneTime"/><TextBox Grid.Row="3" Grid.Column="1" Text="{Binding ElementName=sb1,Path=Value,Mode=OneTime}"/></Grid></StackPanel>
</Window>

课后作业

相关文章:

CH07_数据绑定

第7章&#xff1a;数据绑定 本章目标 理解路由事件 掌握键盘输入事件 掌握鼠标输入事件 掌握多点触控输入事件 数据绑定概述 什么是数据绑定 ​ 将WPF中的至少一个带有依赖项属性的两个对象的两个属性进行绑定&#xff0c;使某一个依赖项属性可以更新和它绑定的属性的功…...

24.python基础(8.8)

python基础 1.搭建环境python3 1.查看是否有安装python [rootpython1 ~]# yum list installed |grep python 2.安装python3 [rootpython1 ~]#yum -y install python3 [rootpython1 ~]#python --version #查看版本信息 最新安装3.12&#xff0c;可以使用源码安装 开…...

【论文阅读】MobileNetV4 - Universal Models for the Mobile Ecosystem

文章目录 摘要一、介绍二、相关工作三、与硬件无关的帕累托效率四、通用倒置瓶颈五、移动MQA六、MNv4模型的设计6.1 为增强的体系结构改进NAS6.2 MNv4模型的优化 7. 结果7.1 ImageNet分类7.2 COCO目标检测 8. 强化蒸馏配方9. 结论 MobileNetV4 - 移动生态系统的通用模型 摘要 …...

大模型日报 2024-08-07

大模型日报 2024-08-07 大模型资讯 [Figure AI 把「终结者」造出来了] 简介&#xff1a;Figure 发布新一代人形机器人 Figure 02&#xff0c;具多种功能&#xff0c;能实时对话、自主执行任务&#xff0c;导航用 VLM&#xff0c;电池续航提升&#xff0c;机械手先进&#xff0c…...

区块链ddos防护怎么做

区块链ddos防护怎么做?在区块链这一新兴技术的浪潮中&#xff0c;我们见证了无数创新应用的诞生与繁荣。然而&#xff0c;在这片充满机遇的蓝海中&#xff0c;也潜藏着不容忽视的暗流——分布式拒绝服务攻击&#xff08;DDoS&#xff09;。DDoS攻击&#xff0c;如同网络世界的…...

在Linux中认识pthread库

int *pnullptr; pnullptr; *pnullptr; 指针变量做右值也是变量拥有空间。去承装数据。 *p代表指针所指向的空间&#xff0c;及0号地址&#xff0c;及往虚拟地址的0号地址处写8个字节的数据&#xff0c;全部写为0. &#xff08;此操作不允许&#xff09; 进程和线程的关系如…...

LVS 负载均衡

目录 LVS 体系结构 LVS 相关概念术语 lvs 集群常见类型 实验一&#xff1a; LVS NAT模式 LVS NAT特性 实验二&#xff1a; LVS DR模式 LVS DR特性 LVS是Linux virtual server的缩写&#xff0c;是一个高性能的、开源的负载均衡器&#xff0c;它运行于Linux操作系统之上…...

在Excel中启用宏 (~ ̄▽ ̄)~

一、启用宏 打开任意Excel&#xff0c;点击屏幕左上角的文件选项&#xff0c;然后选择Excel选项窗口。在Excel选项窗口中&#xff0c;选择信任中心按钮&#xff1b;在信任中心设置窗口中&#xff0c;选择宏设置&#xff0c;启用所有宏&#xff08;不推荐&#xff0c;潜在风险&a…...

连接投影仪/显示器只能扩展不能复制的解决方案

原文章&#xff1a;https://iknow.lenovo.com.cn/detail/121481 故障现象&#xff1a; 笔记本外接投影仪/显示器后&#xff0c;笔记本屏幕有显示&#xff0c;但投影仪却只有背景或没有显示&#xff1b; 原因分析&#xff1a; 此现象多发生在双显卡机型上&#xff0c;笔记本屏…...

数据库基础知识

数据库基础知识 主流的数据库连接MySQL理解mysql和mysqld和数据库简单对数据库操作MySQL构架SQL分类存储引擎总结 主流的数据库 SQL Sever&#xff1a; 微软的产品&#xff0c;.Net程序员的最爱&#xff0c;中大型项目。Oracle&#xff1a; 甲骨文产品&#xff0c;适合大型项目…...

java JVM 锁消除

Java虚拟机 (JVM) 中的锁消除 (Lock Elimination) 是一种编译时优化技术&#xff0c;用于减少或完全去除不必要的同步操作。锁消除可以显著提高程序的性能&#xff0c;尤其是在多线程环境中。下面详细介绍锁消除的工作原理和技术细节。 锁消除的目的 锁消除的目标是在编译阶段…...

基于 Java Supplier与Predicate 封装自动重试机制通用接口

核心逻辑就是把重试的业务与重试中断条件抽象出来函数化&#xff0c;内部重试业务具体化。 关键需要理解Java的函数式接口编程 Supplier 与 Predicate作用。 import lombok.Data; import lombok.extern.slf4j.Slf4j;import java.util.Random; import java.util.function.Predi…...

Java面试题(基础篇)②

目录 一&#xff0c;float f3.4 是否正确&#xff1f; 二&#xff0c;重写和重载的区别是什么 三&#xff0c;this和super的应用场景是什么 四&#xff0c;throw和throws的区别是什么 五&#xff0c;应该使用什么数据类型来计算价格 一&#xff0c;float f3.4 是否正确&am…...

【docker快捷部署系列二】用docker-compose快速配置多个容器,docker部署Springboot+Vue项目和mysql数据库

1、思路 docker部署项目是将项目的不同程序放入不同容器中运行&#xff0c;这样可以方便管理不同程序。我的项目有Springboot、Vue、mysql三部分&#xff0c;Vue用nginx代理&#xff0c;因为nodejs太占空间了。一开始我是用Dockerfile创建镜像再运行容器的&#xff0c;但发现它…...

Java新手指南:从菜鸟到编程大师的趣味之路-类和对象

这里是Themberfue 本章主要介绍的是Java最重要的面向对象&#xff08;OOP&#xff09;的基础 面向对象 Java是一门纯面向对象的语言&#xff0c;在面向对象的世界里&#xff0c;一切皆为对象。面向对象是解决问题的一种思想&#xff0c;主要依靠对象之间的交互完成一件事情。用…...

计算机毕业设计选题推荐-房屋租赁系统-Java/Python项目实战

✨作者主页&#xff1a;IT研究室✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Python…...

LeetCode 3131.找出与数组相加的整数 I:最小值之差(多语言一行版)

【LetMeFly】3131.找出与数组相加的整数 I&#xff1a;最小值之差&#xff08;多语言一行版&#xff09; 力扣题目链接&#xff1a;https://leetcode.cn/problems/find-the-integer-added-to-array-i/ 给你两个长度相等的数组 nums1 和 nums2。 数组 nums1 中的每个元素都与…...

Win32注册表操作

注册表的概念 注册表是一个存储计算机配置信息的数据库&#xff0c;用于存储计算机上的硬件、安装的软件、系统设置以及用户账户配置等重要信息。对注册表的编辑不当可能会影响计算机的正常运行。应用程序可以调用API函数来对注册表进行增、删等操作。 注册表结构 运行Regedi…...

白骑士的PyCharm教学高级篇 3.3 Web开发支持

系列目录 上一篇&#xff1a;白骑士的PyCharm教学高级篇 3.2 多模块项目管理 在现代Web开发中&#xff0c;前端技术的重要性日益增加。PyCharm不仅在后端开发中表现出色&#xff0c;在前端开发方面也提供了丰富的支持。本文将详细介绍PyCharm中对HTML、CSS、JavaScript的编辑支…...

SpringAOP-底层实现源码解析

目录 1. Spring AOP原理流程图 2. 动态代理 3. ProxyFactory 4. Advice的分类 5. Advisor的理解 6. 创建代理对象的方式 ProxyFactoryBean BeanNameAutoProxyCreator DefaultAdvisorAutoProxyCreator 7. 对Spring AOP的理解 8. AOP中的概念 9. Advice在Spring AOP中…...

33、请求处理【源码分析】Servlet API参数解析原理

33、请求处理【源码分析】Servlet API参数解析原理 在 Spring Boot 中&#xff0c;请求处理过程中涉及到 **Servlet API 参数解析** 的核心机制&#xff0c;主要依赖于 HandlerMethodArgumentResolver 接口及其相关实现类。以下是其原理的详细分析&#xff1a; --- ### **1. 参…...

使用yocto搭建qemuarm64环境

环境 yocto下载 # 源码下载 git clone git://git.yoctoproject.org/poky git reset --hard b223b6d533a6d617134c1c5bec8ed31657dd1268 构建 # 编译镜像 export MACHINE"qemuarm64" . oe-init-build-env bitbake core-image-full-cmdline 运行 # 跑虚拟机 export …...

游戏引擎学习第314天:将精灵拆分成多个层

回顾并为今天的工作做准备 我们今天继续昨天开始的工作&#xff0c;现在我们要回到渲染中处理 Z 值的最终环节。我们目前已经有一个我们认为还算合理的排序方式&#xff0c;虽然可能还需要在接下来的过程中进行一些调整&#xff0c;但总体上已经有了一个明确的方向。 我们已经…...

【HW系列】—溯源与定位—Linux入侵排查

文章目录 一、Linux入侵排查1.账户安全2.特权用户排查&#xff08;UID0&#xff09;3.查看历史命令4.异常端口与进程端口排查进程排查 二、溯源分析1. 威胁情报&#xff08;Threat Intelligence&#xff09;2. IP定位&#xff08;IP Geolocation&#xff09;3. 端口扫描&#x…...

8.8 Primary ODSA service without ODSA Portal

主要ODSA服务&#xff08;不使用ODSA门户&#xff09; 以下场景描述如下情况&#xff1a; • 主ODSA客户端应用程序被允许用于该类型的主设备&#xff0c;且对终端用户启用&#xff08;已授权&#xff09;。 • 服务提供商&#xff08;SP&#xff09;能够在不涉及ODSA门户Web服…...

QNAP MEMOS 域名访问 SSL(Lucky)

注意&#xff1a;下述是通过ssh、docker-compose方式安装docker的&#xff0c;不是直接在container station中安装的哈&#xff01;&#xff01;&#xff01; 一、编辑docker-compose.yml文件 用“#”号标识的&#xff0c;在保存文件的时候建议去掉&#xff0c;不然有时候会出…...

java操作服务器文件(把解析过的文件迁移到历史文件夹地下)

第一步导出依赖 <dependency><groupId>org.apache.sshd</groupId><artifactId>sshd-core</artifactId><version>2.13.0</version></dependency> 第二步写代码 public void moveFile( List<HmAnalysisFiles> hmAnalys…...

大模型运维过程中常见的一些操作

1. 模型部署与环境配置 基础设施准备&#xff1a;部署 GPU 集群、TPU 等专用硬件&#xff0c;配置分布式计算环境&#xff08;如 Kubernetes&#xff09;。推理服务搭建&#xff1a;使用 Triton Inference Server、TensorFlow Serving 等框架部署模型&#xff0c;优化批处理和…...

RuoYi前后端分离框架实现前后端数据传输加密(一)之后端篇

一、背景 项目采用RuoYi前后端分离框架搭建,版本为3.8.9。为确保数据传输安全性,提高爬虫获取数据的门槛,领导要求系统指定的字段在API通信过程中要实现加密传输,但未对算法类型做具体要求,本人基于目前的新创的大环境考虑,采用了SM4对称加密算法对系统指定字段进行加密…...

LG P4119 [Ynoi2018] 未来日记 Solution

Description 给定序列 a ( a 1 , a 2 , ⋯ , a n ) a(a_1,a_2,\cdots,a_n) a(a1​,a2​,⋯,an​)&#xff0c;有 m m m 个操作分两种&#xff1a; replace ⁡ ( l , r , x , y ) \operatorname{replace}(l,r,x,y) replace(l,r,x,y)&#xff1a;将 a l ∼ a r a_l\sim a_r …...