WPF、控件模板(ControlTemplate)和数据模板(DataTemplate)

news2025/4/21 15:45:36

前言

在 WPF 中,控件种类丰富且功能非常完善。一个显著的优点是 WPF 提供了强大的自定义能力和灵活的用户界面表现,能够满足各种复杂的应用需求。其中,ControlTemplate 和 DataTemplate 是两个非常重要的概念,分别用于自定义控件的外观和定义数据的展示方式。

控件模板(ControlTemplate)

ControlTemplate 主要用于自定义控件的外观,而不改变控件的行为。由于WPF默认控件的样式不是特别美观,ControlTemplate 它允许自定义控件的视觉元素,例如按钮的外观、文本框的边框等等,而不需要改变控件的内部逻辑或数据。ControlTemplate 也是一个 XAML 模板。

基本语法

<ControlTemplate x:Key="CustomerTemplate" TargetType="{x:Type 控件类型}">

</ControlTemplate>

ControlTemplate有两个重要的属性,VisualTree另一个是Triggers。

  • VisualTree,定义模板的视觉树结构,其实我们就是使用这个属性来描述控件的外观的。
  • Triggers,触发器列表,里面包含一些触发器Trigger,我们可以定制这个触发器列表来使控件对外界的刺激发生反应,比如鼠标经过时文本变成粗体等。

下面我就基于比较常用的Button来演示一下,如何自定义Button样式。

<Window x:Class="WpfApp1.ControlTemplateWindow"
        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:WpfApp1"
        mc:Ignorable="d"
        Title="ControlTemplateWindow" Height="450" Width="800">

    <Window.Resources>
    </Window.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>

        <Button Grid.Column="0" Grid.Row="0" Content="默认按钮" Margin="0 10 0 0"></Button>

        <Button Grid.Column="2" Grid.Row="0" Content="自定义按钮1" Foreground="White" FontSize="12" FontWeight="Bold" Margin="0 10 0 0" Cursor="Hand">
            <Button.Style>
                <Style TargetType="Button">
                    <Setter Property="Background" Value="#409eff"/>
                    <Setter Property="BorderBrush" Value="White"/>
                </Style>
            </Button.Style>
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="7">
                        <Grid>
                            <!--Rectangle是用于绘制矩形,Fill填充颜色,RadiusX/Y 是绘制矩形的CornerRadius,Opacity透明度 -->
                            <Rectangle Name="CustomerOverlay" Fill="White" Opacity="0" RadiusX="7" RadiusY="7" />
                            <Rectangle Name="CustomerPressed" Fill="Black" Opacity="0" RadiusX="7" RadiusY="7" />
                            <!-- 按钮的内容 -->
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <!-- 触发器 -->
                    <ControlTemplate.Triggers>
                        <!-- 点击按钮时触发 -->
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="CustomerPressed" Property="Opacity" Value="0.3"/>
                        </Trigger>
                        <!-- 鼠标移动到按钮时触发 -->
                        <Trigger Property="Button.IsMouseOver" Value="True">
                            <Setter TargetName="CustomerOverlay" Property="Opacity" Value="0.2"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Button.Template>
        </Button>

    </Grid>
</Window>

代码看着有点多,其实很简单,复制到自己本地,就可以运行,大家可以试一下。

简单解释下代码:

  • ControlTemplate:我们定义了一个简单的ControlTemplate,该模板的目标类型是Button。
  • Grid:定义一个布局(类似HTML的div),该布局中就是具体的自定义样式的内容。里面我加了两个图层,一个是在鼠标悬停时展示,另一个是鼠标点击按钮时展示。我在Grid外面还包了一个Border边框。
  • ContentPresenter:这是一个占位符,用来显示按钮的内容。它确保我们可以在按钮中显示文本或其他控件。
  • TemplateBinding:用于将模板中控件的某个属性绑定到其父控件的某个属性。在此示例中,BorderBrush绑定到按钮的BorderBrush、Background属性。
  • Triggers:触发器,具体每个控件的触发器会不同,大家可以参考微软官网中WPF具体每个控件模板。

需要注意的是,ControlTemplate中的内容一般放到Window.Resources中。

具体执行效果如下所示:

当鼠标悬停在按钮上时,按钮会显示一个高亮图层;点击按钮后,会展示一个新的图层效果。这是基于element-plus按钮组件的样式用WPF实现的,下面我把element-plus上比较常用的按钮组件,用WPF实现看看效果。

<Window x:Class="WpfApp1.ControlTemplateWindow"
        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:WpfApp1"
        mc:Ignorable="d"
        Title="ControlTemplateWindow" Height="450" Width="800">

    <Window.Resources>
        <ControlTemplate x:Key="CustomButtonTemplate" TargetType="Button">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="7">
                <Grid>
                    <!-- Rectangle用于绘制矩形,Fill填充颜色,RadiusX/Y绘制矩形的CornerRadius,Opacity透明度 -->
                    <Rectangle Name="CustomerOverlay" Fill="White" Opacity="0" RadiusX="7" RadiusY="7" />
                    <Rectangle Name="CustomerPressed" Fill="Black" Opacity="0" RadiusX="7" RadiusY="7" />
                    <!-- 按钮的内容 -->
                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Grid>
            </Border>
            <!-- 触发器 -->
            <ControlTemplate.Triggers>
                <!-- 点击按钮时触发 -->
                <Trigger Property="IsPressed" Value="True">
                    <Setter TargetName="CustomerPressed" Property="Opacity" Value="0.3"/>
                </Trigger>
                <!-- 鼠标移动到按钮时触发 -->
                <Trigger Property="Button.IsMouseOver" Value="True">
                    <Setter TargetName="CustomerOverlay" Property="Opacity" Value="0.2"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        
        <ControlTemplate  x:Key="CustomIconButtonTemplate" TargetType="Button">
            <Grid>
                <Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
                <Image Source="/images/收藏.png" Width="18" />

                <Ellipse Name="CustomerOverlay" Fill="White" Opacity="0" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
                <Ellipse Name="CustomerPressed" Fill="Black" Opacity="0" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
            </Grid>
            <!-- 触发器 -->
            <ControlTemplate.Triggers>
                <!-- 点击按钮时触发 -->
                <Trigger Property="IsPressed" Value="True">
                    <Setter TargetName="CustomerPressed" Property="Opacity" Value="0.3"/>
                </Trigger>
                <!-- 鼠标移动到按钮时触发 -->
                <Trigger Property="Button.IsMouseOver" Value="True">
                    <Setter TargetName="CustomerOverlay" Property="Opacity" Value="0.2"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <ControlTemplate x:Key="CustomImageButtonTemplate" TargetType="Button">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="7">
                <Grid>
                    <Rectangle Name="CustomerOverlay" Fill="White" Opacity="0" RadiusX="7" RadiusY="7" />
                    <Rectangle Name="CustomerPressed" Fill="Black" Opacity="0" RadiusX="7" RadiusY="7" />
                    <!-- 按钮的内容 -->
                    <WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                        <ContentPresenter Content="下载" VerticalAlignment="Center" Margin="0 0 8 0"/>
                        <Image Source="/images/下载.png" Width="15" />
                    </WrapPanel>
                </Grid>
            </Border>
            <!-- 触发器 -->
            <ControlTemplate.Triggers>
                <!-- 点击按钮时触发 -->
                <Trigger Property="IsPressed" Value="True">
                    <Setter TargetName="CustomerPressed" Property="Opacity" Value="0.3"/>
                </Trigger>
                <!-- 鼠标移动到按钮时触发 -->
                <Trigger Property="Button.IsMouseOver" Value="True">
                    <Setter TargetName="CustomerOverlay" Property="Opacity" Value="0.2"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>

        <Button Grid.Column="0" Grid.Row="0" Content="默认按钮" Margin="0 10 0 0"></Button>

        <Button Grid.Column="2" Grid.Row="0" 
                Content="自定义按钮1" 
                Foreground="White" 
                FontSize="12" 
                FontWeight="Bold" 
                Background ="#409eff"
                BorderBrush="White"
                Margin="0 10 0 0" 
                Cursor="Hand"
                Template="{StaticResource CustomButtonTemplate}">
        </Button>

        <Button Grid.Column="4" Grid.Row="0" 
                Margin="0 10 0 0" 
                Background="#e6a23c"
                Width="30"
                Height="30"
                Cursor="Hand"
                Template="{StaticResource CustomIconButtonTemplate}">
        </Button>

        <Button Grid.Column="6" Grid.Row="0" 
                Margin="0 10 0 0" 
                Foreground="White"
                Background="#409eff"
                BorderBrush="White"
                Cursor="Hand"
                Template="{StaticResource CustomImageButtonTemplate}">
        </Button>

    </Grid>
</Window>

具体效果如下所示:

 还有更多炫酷的自定义样式,比如添加一个动画效果,但是这种样式,对于我目前刚刚学习WPF来说不太需要,等后面需要用到再了解。

数据模板(DataTemplate)

ControlTemplate 主要用于自定义控件的外观,它改变控件的整体结构和样式,通常用于修改控件的框架(例如按钮的样式)。而当控件内部需要显示与数据相关的内容时,就需要使用 DataTemplate。DataTemplate 定义了数据对象的外观,控制了数据项的可视化方式,特别是在使用像 ItemsControl、ListBox 或 DataGrid 等控件时,DataTemplate 会决定如何呈现绑定的数据项。

基本语法

<DataTemplate x:Key="CustomerDataTemplate">
   
</DataTemplate>

DataTemplate重要属性:

  • VisualTree,定义每个数据项的样式。
  • Triggers,触发器当绑定的数据满足某个条件时,可以去设置一些控件的属性值,这个与ControlTemplate中的Triggers还不一样。

下面我将以ListBox为例,自定义ListBox的样式

前端页面代码:

<Window x:Class="WpfApp1.DataTemplateWindow"
        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:WpfApp1"
        mc:Ignorable="d"
        Title="DataTemplateWindow" Height="450" Width="800">

    <Window.Resources>
       
    </Window.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition/>
        </Grid.RowDefinitions>

        <ListBox Grid.Row="0" 
                 x:Name="DefaultListBox" 
                 HorizontalContentAlignment="Stretch"
                 >
        </ListBox>

        <ListBox Grid.Row="1" x:Name="CustomerListBox" HorizontalContentAlignment="Stretch">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Margin" Value="0 10 0 0"/>
                    <!-- 去掉背景 -->
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="BorderBrush" Value="Transparent"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    
                </Style>
            </ListBox.ItemContainerStyle>
            <!-- ListBox中的内容排列方向 -->
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <WrapPanel Orientation="Horizontal"  >
                        <Border  Background="{Binding TagColor}" CornerRadius="3" Width="70" Height="25" >
                            <TextBlock 
                                   Text="{Binding TagName}" 
                                   Width="70" 
                                   Height="25" 
                                   TextAlignment="Center"
                                   Foreground="White"
                                   Padding="0 5 0 0"
                                   />
                        </Border>
                        <Image Source="/images/删除.png" x:Name="ShowImg" Width="15" Margin="-18 0 0 0" Visibility="Hidden"  Cursor="Hand" />

                    </WrapPanel>

                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding TagDelete}" Value="True">
                            <Setter TargetName="ShowImg" Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </DataTemplate.Triggers>
                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


    </Grid>
</Window>

后台代码:

using System;
using System.Collections.Generic;
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.Shapes;

namespace WpfApp1
{
    /// <summary>
    /// DataTemplateWindow.xaml 的交互逻辑
    /// </summary>
    public partial class DataTemplateWindow : Window
    {
        public DataTemplateWindow()
        {
            InitializeComponent();

            var tagList = new List<TagInfo>()
            {
                new TagInfo()
                {
                    TagName = "Tag 1",
                    TagColor = "#409eff"
                },
                new TagInfo()
                {
                    TagName = "Tag 2",
                    TagColor = "#67c23a",
                    TagDelete = true
                },
                new TagInfo()
                {
                    TagName = "Tag 3",
                    TagColor = "#909399"
                },
            };

            DefaultListBox.ItemsSource = tagList;
            CustomerListBox.ItemsSource = tagList;
        }
    }

    public class TagInfo
    {
        public string TagName { get; set; }
        public string TagColor { get; set; }
        public bool TagDelete { get; set; } = false;
        public override string ToString()
        {
            return TagName;  // 使用 TagName 作为默认显示内容
        }
    }
}

执行效果:

代码也很简单,稍微解释一下:

  • ItemContainerStyle,设置每个数据项的样式。
  • ItemsPanel,设置数据集的排列方向。
  • ItemTemplate,设置每个数据项的具体自定义样式,里面就有DataTemplate。

需要注意的是,上面说的ItemContainerStyle、ItemsPanel、ItemTemplate这并不是每个数据集的控件都支持,具体还需要看官网每个控件支持的是哪些。

DataTemplate中的内容一般也是放到Window.Resources中。

<Window x:Class="WpfApp1.DataTemplateWindow"
        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:WpfApp1"
        mc:Ignorable="d"
        Title="DataTemplateWindow" Height="450" Width="800">

    <Window.Resources>
        <Style x:Key="CustomListBoxItemStyle" TargetType="ListBoxItem">
            <Setter Property="Margin" Value="0 10 0 0"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
        </Style>

        <!-- ItemTemplate -->
        <DataTemplate x:Key="CustomItemTemplate">
            <WrapPanel Orientation="Horizontal">
                <Border Background="{Binding TagColor}" CornerRadius="3" Width="70" Height="25">
                    <TextBlock Text="{Binding TagName}" Width="70" Height="25" TextAlignment="Center"
                               Foreground="White" Padding="0 5 0 0"/>
                </Border>
                <Image Source="/images/删除.png" x:Name="ShowImg" Width="15" Margin="-18 0 0 0"
                       Visibility="Hidden" Cursor="Hand"/>
            </WrapPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding TagDelete}" Value="True">
                    <Setter TargetName="ShowImg" Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </Window.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition/>
        </Grid.RowDefinitions>

        <ListBox Grid.Row="0" 
                 x:Name="DefaultListBox" 
                 HorizontalContentAlignment="Stretch"
                 >
        </ListBox>

        <ListBox Grid.Row="1" x:Name="CustomerListBox" HorizontalContentAlignment="Stretch"
                 ItemContainerStyle="{StaticResource CustomListBoxItemStyle}"
                 ItemTemplate="{StaticResource CustomItemTemplate}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>


    </Grid>
</Window>

总结

在 WPF 中,ControlTemplate和DataTemplate 是非常强大且重要的功能,它们分别用于自定义控件的外观和数据展示的方式。只有在用到某些控件需要自定义样式的时候,再具体了解,因为每个控件自定义模板是不一样的,本篇文章只是根据Button和ListBox简单实现这两个控件的自定义样式。如果有不同的需求,大家具体可以看下微软的模板库,里面有每个控件模板涉及需要修改的点。

后面我会用每个控件都实现自定义样,包括下拉控件、分页控件、时间控件等等,实现效果以经常使用的场景为主。

控件样式和模板 - WPF .NET Framework | Microsoft Learn

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2277432.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Redis十大数据类型详解

Redis&#xff08;一&#xff09; 十大数据类型 redis字符串&#xff08;String&#xff09; string是redis最基本的类型&#xff0c;一个key对应一个value string类型是二进制安全的&#xff0c;意思是redis的string可以包含任何数据。例如说是jpg图片或者序列化对象 一个re…

Python Wi-Fi密码测试工具

Python Wi-Fi测试工具 相关资源文件已经打包成EXE文件&#xff0c;可双击直接运行程序&#xff0c;且文章末尾已附上相关源码&#xff0c;以供大家学习交流&#xff0c;博主主页还有更多Python相关程序案例&#xff0c;秉着开源精神的想法&#xff0c;望大家喜欢&#xff0c;点…

qml AngleDirection详解

1、概述 AngleDirection 是 QML&#xff08;Qt Meta Language&#xff09;中用于定义粒子发射方向的一个类&#xff0c;它属于 Qt Quick Particles 模块。AngleDirection 通过设置角度范围来控制粒子从发射器射出时的初始方向。这个类在创建具有特定发射模式的粒子效果时非常有…

VSCode使用纪要

1、常用快捷键 1&#xff09;注释 ctrl? 单行注释&#xff0c; altshifta 块注释&#xff0c; 个人测试&#xff0c;ctrl? 好像也能块注释 2&#xff09;开多个项目 可以先开一个新窗口&#xff0c;再新窗口打开另一个项目&#xff0c;这时就是同时打开多个项目了。 打开…

单独编译QT子模块

单独编译QT子模块 系统 win qt-everywhere-src-5.12.12 下载源码&#xff1a; https://download.qt.io/archive/qt/5.12/5.12.12/single/ 参考&#xff1a; https://doc.qt.io/qt-5/windows-building.html 安装依赖 https://doc.qt.io/qt-5/windows-requirements.html Per…

浙江安吉成新照明电器:Acrel-1000DP 分布式光伏监控系统应用探索

安科瑞吕梦怡 18706162527 摘 要&#xff1a;分布式光伏发电站是指将光伏发电组件安装在用户的建筑物屋顶、空地或其他适合的场地上&#xff0c;利用太阳能进行发电的一种可再生能源利用方式&#xff0c;与传统的大型集中式光伏电站相比&#xff0c;分布式光伏发电具有更灵活…

DAMA GDPA 备考笔记(二)

1. 考点分布 2. 第二章 数据处理伦理知识点总结 伦理是建立在是非观念上的行为准则。伦理准则通常侧重于公平、尊重、责任、诚信、质量、可靠性、透明度和信任等方面。数据伦理是一项社会责任问题不是法律问题。 度量指标&#xff1a;培训员工人数、合规/不合规事件、企业高管…

Unity中实现倒计时结束后干一些事情

问题描述&#xff1a;如果我们想实现在一个倒计时结束后可以执行某个方法&#xff0c;比如挑战成功或者挑战失败&#xff0c;或者其他什么的比如生成boss之类的功能&#xff0c;而且你又不想每次都把代码复制一遍&#xff0c;那么就可以用下面这种方法。 结构 实现步骤 创建一…

【Elasticsearch】filterQuery过滤查询

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家&#xff0c;历代文学网&#xff08;PC端可以访问&#xff1a;https://literature.sinhy.com/#/?__c1000&#xff0c;移动端可微信小程序搜索“历代文学”&#xff09;总架构师&#xff0c;15年工作经验&#xff0c;精通Java编…

带头双向循环链表(数据结构初阶)

文章目录 双向链表链表的分类概念与结构实现双向链表定义链表结构链表打印判空申请结点初始化头插尾插头删尾删查找指定位置插入和删除销毁链表 顺序表和链表的分析结语 欢迎大家来到我的博客&#xff0c;给生活来点impetus&#xff01;&#xff01; 这一节我们学习双向链表&a…

在eNSp上telnet一下吧

在上篇博客&#xff1a;DNS 我们提到了telnet和设备带外管理、带内管理&#xff0c;它确实是非常有趣的一个知识点哦&#xff0c;接下来我们一起来学习学习吧~ Telnet&#xff08;远程登陆协议&#xff09; Telnet基于TCP 23号端口&#xff0c;典型的C/S架构模式&#xff0c;是…

Spring MVC复杂数据绑定-绑定集合

【图书介绍】《SpringSpring MVCMyBatis从零开始学&#xff08;视频教学版&#xff09;&#xff08;第3版&#xff09;》_【新华文轩】springspring mvcmybatis从零开始学(视频教学版) 第3版 正版-CSDN博客 《SpringSpring MVCMyBatis从零开始学(视频教学版)&#xff08;第3版…

基于禁忌搜索算法的TSP问题最优路径搜索matlab仿真

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 5.完整程序 1.程序功能描述 基于禁忌搜索算法的TSP问题最优路径搜索&#xff0c;旅行商问题&#xff08;TSP&#xff09;是一个经典的组合优化问题。其起源可以追溯到 19 世纪初&#xff0c;…

静态综合路由实验

实验拓扑 实验要求 1.除R5的环回地址外&#xff0c;整个其他所有网段基于192.168.1.0/24进行合理的IP地址划分 2.R1-R4每个路由器存在两个环回接口&#xff0c;用于模拟pc网段&#xff1b;地址也在192.168.1.0/24这个网络范围内 3.R1-R4上不能直接编写到达5.5.5.0/24的静态路由…

前端组件开发:组件开发 / 定义配置 / 配置驱动开发 / 爬虫配置 / 组件V2.0 / form表单 / table表单

一、最早的灵感 最早的灵感来自sprider / 网络爬虫 / 爬虫配置&#xff0c;在爬虫爬取网站文章时候&#xff0c;会输入给爬虫一个配置文件&#xff0c;里边的内容是一个json对象。里边包含了所有想要抓取的页面的信息。爬虫通过这个配置就可以抓取目标网站的数据。其实本文要引…

[Deep Learning] Anaconda+CUDA+CuDNN+Pytorch(GPU)环境配置-2025

文章目录 [Deep Learning] AnacondaCUDACuDNNPytorch(GPU)环境配置-20250. 引子1. 安装Anaconda1.1 安装包下载&#xff1a;1.2 启用安装包安装1.3 配置(系统)环境变量1.4 验证Anaconda是否安装完毕1.5 Anaconda换源 2. 安装CUDACuDNN2.1 判断本机的CUDA版本2.2 下载适合自己CU…

直播预告丨Arxiv Insight:用 AI 重新定义论文检索

1月16日晚上20:00-20:50&#xff0c;Zilliz直播间&#xff0c;深圳大学计算机视觉所硕士牛增豪先生将带来《Arxiv Insight&#xff1a;用 AI 重新定义论文检索》分享&#xff0c;届时他将讲述从零到一构建 Arxiv Insight产品的过程&#xff0c;思考以及未来计划。欢迎大家锁定Z…

STM32 FreeRTOS 的任务挂起与恢复以及查看任务状态

目录 任务的挂起与恢复的API函数 任务挂起函数 任务恢复函数 任务恢复函数&#xff08;中断中恢复&#xff09; 函数说明 注意事项 查看任务状态 任务的挂起与恢复的API函数 vTaskSuspend()&#xff1a;挂起任务, 类似暂停&#xff0c;可恢复 vTaskResume()&#xff1a…

4. 使用springboot做一个音乐播放器软件项目【数据库表的创建】

上一章文章 我们做了音乐播放器 这个项目一些公共封装的一些工具类。参考网址&#xff1a; https://blog.csdn.net/Drug_/article/details/145093705 那么这篇文章 我们开始创建数据表。来存储我们项目中所需要存储的数据。 对于 我们这个项目 版本一 需要开发的核心功能 在 第…

leetcode刷题记录(五十四)——560. 和为 K 的子数组

&#xff08;一&#xff09;问题描述 560. 和为 K 的子数组 - 力扣&#xff08;LeetCode&#xff09;560. 和为 K 的子数组 - 给你一个整数数组 nums 和一个整数 k &#xff0c;请你统计并返回 该数组中和为 k 的子数组的个数 。子数组是数组中元素的连续非空序列。 示例 1&am…