CH07_数据绑定

news2024/9/26 3:32:36

第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>

课后作业

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

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

相关文章

奥尔特曼在X上发了颗“草莓” 网友疯狂猜测:这难道是GPT新模型?

ChatGPT开发商OpenAI的首席执行官山姆奥尔特曼&#xff08;Sam Altman&#xff09;在社交媒体X上发布了一张花园里自种草莓的照片后&#xff0c;引发了众多网友的热议&#xff0c;是否新的GPT模型即将上线&#xff1f; 周三&#xff08;8月7日&#xff09;&#xff0c;奥尔特曼…

海量数据处理商用短链接生成器平台 - 8

第十八章 短链服务-分库分表多维度查询解决方案《钻石玩法》 第1集 短链服务-短链URL跳转302跳转接口开发实战 简介&#xff1a; 短链URL 跳转302跳转接口开发实战 需求 接收一个短链码解析获取原始地址302进行跳转 编码实战 Controller Slf4j public class LinkApiControl…

搭建时空基底,建设“数字之城”

在这个日新月异的时代&#xff0c;数字技术正以前所未有的速度重塑我们的世界。今天&#xff0c;让我们一同深入探讨如何通过搭建时空基底&#xff0c;为“数字之城”的建设奠定坚实基础。 一、时空基底&#xff1a;数字之城的骨骼与脉络 所谓“时空基底”&#xff0c;是指结…

【vulnhub】DC-6靶机

靶机安装 下载地址&#xff1a;https://download.vulnhub.com/dc/DC-6.zip 运行靶机&#xff1a;VMware 信息收集 靶机扫描 nmap 192.168.93.0/24 端口扫描,根据80端口的信息&#xff0c;发现我们并不能直接访问靶机的web页面&#xff0c;和/wordy相关 nmap -A 192.168.9…

本地部署MySQL图形化管理工具phpMyAdmin结合内网穿透远程访问

文章目录 前言1. 安装MySQL2. 安装phpMyAdmin3. 修改User表4. 本地测试连接MySQL5. 安装cpolar内网穿透6. 配置MySQL公网访问地址7. 配置MySQL固定公网地址8. 配置phpMyAdmin公网地址9. 配置phpmyadmin固定公网地址 前言 本文主要介绍如何在群晖NAS安装MySQL与数据库管理软件p…

C++虚函数表、地址详解(x86/x64)

参考博文&#xff1a;c虚函数表、地址详解-CSDN博客 本文在上述博文的基础上&#xff0c;补充了x64下的验证代码。 一.什么是虚函数表&#xff0c;它有什么特点&#xff1f; 虚函数大家都知道是基本用于实现多态的&#xff0c;当父类指针指向子类对象的时候&#xff0c;如何确…

国自然即将放榜,还没消息是不是就凉了?

本周投稿推荐 SCI&EI • 医学与心理学&#xff0c;纯正刊&#xff08;基本不拒稿&#xff09; • 1区计算机水刊&#xff0c;3.5-4.0&#xff08;1个月录用&#xff09; • 2区-Top水刊&#xff0c;2.0-3.0&#xff08;沾边可录&#xff09; EI • 各领域沾边均可&am…

超分辨率重建——冠军队EDVR视频超分网络训练自己数据集与推理测试(详细图文教程)

&#x1f4aa; 专业从事且热爱图像处理&#xff0c;图像处理专栏更新如下&#x1f447;&#xff1a; &#x1f4dd;《图像去噪》 &#x1f4dd;《超分辨率重建》 &#x1f4dd;《语义分割》 &#x1f4dd;《风格迁移》 &#x1f4dd;《目标检测》 &#x1f4dd;《暗光增强》 &a…

LeetCode刷题笔记第17题:电话号码的字母组合

LeetCode刷题笔记第17题&#xff1a;电话号码的字母组合 题目&#xff1a; 想法&#xff1a; 先构建手机号码的字典&#xff0c;利用回溯的思想&#xff0c;组合数字对应的字母&#xff0c;代码如下&#xff1a; class Solution:def letterCombinations(self, digits: str) …

Animate软件基本概念:元件(影片剪辑、图形、按钮)

这一篇是说明Animate软件中常见的几种元件类型的定义。 FlashASer&#xff1a;AdobeAnimate2021软件零基础入门教程https://zhuanlan.zhihu.com/p/633230084 FlashASer&#xff1a;实用的各种Adobe Animate软件教程https://zhuanlan.zhihu.com/p/675680471 FlashASer&#x…

数据结构:栈与队列OJ题

目录 前言 一、用栈实现队列 二、用队列实现栈 三、括号匹配问题 前言 前面讲了栈和队列的基础知识&#xff0c;今天来巩固一下加深理解&#xff0c;这里说明一下&#xff0c;因为现在都是在用C语言写&#xff0c;这些OJ题里都要用到前面实现栈和队列的代码&#xff0c;每道题…

Java 自定义注解 笔记总结(油管)

Java系列文章目录 IDEA使用指南 Java泛型总结&#xff08;快速上手详解&#xff09; Java Lambda表达式总结&#xff08;快速上手详解&#xff09; Java Optional容器总结&#xff08;快速上手图解&#xff09; Java 自定义注解笔记总结&#xff08;油管&#xff09; Jav…

AI时代,我们还可以做什么?

最近看了本书&#xff0c;书名叫做《拐点&#xff1a;站在 AI 颠覆世界的前夜》&#xff0c;作者是万维钢。 本想着看完后&#xff0c;就能掌握一整套 AI 技巧&#xff0c;结果——竟然学了很多道理。 这本书讨论了以下话题&#xff1a; 我们该怎么理解这个 AI 大时代的哲学&am…

思迈特发布全新AI应用,Smartbi AIChat白泽来了

8月8日&#xff0c;Smartbi AIChat白泽新品发布会在云端与大家如期美好相约&#xff0c;共同见证思迈特软件基于AI Agent的新一代智能BI应用落地的全新里程碑时刻。 思迈特软件创始人吴华夫和产品总监杨礼显先后围绕商业智能行业发展趋势、产品demo show、技术原理及未来规划展…

Mysql,用户名重复,无法调用问题

问题描述&#xff1a; 我电脑的数据库用户名是&#xff0c;root。 因为经常需要帮别人封装程序&#xff0c;所以需要在我本机跑通别人的程序。有的程序里面也涉及到数据库&#xff0c;用户名也是&#xff0c;root&#xff0c;但是密码与我本机的不同。 之前我会修改我用户名…

【LVS】防火墙mark标记解决调度问题

实验环境是在之前部署DR模式集群的基础上做的&#xff0c;参考如下 部署DR模式集群 以http和https为例&#xff0c;当我们在webserver中同时开放80和443端口&#xff0c;那么默认控制是分开轮询的&#xff0c;就会出现了一个轮询错乱的问题&#xff1a; 当第一次访问80被轮询…

为什么要用数据库管理系统?5个你不得不知道的理由

你是否曾经想过,为什么几乎所有的企业和组织都在使用数据库管理系统(DBMS)?为什么不直接使用文件系统来存储和管理数据呢?如果你有这样的疑问,那么这篇文章正是为你而写。在接下来的内容中,我们将深入探讨使用数据库管理系统的5个关键原因,这些原因将彻底改变你对数据管理的认…

【Kubernetes】pod状态与故障排查

一、Pod启动阶段&#xff08;相位 phase&#xff09; pod创建完之后&#xff0c;一直到持久运行起来&#xff0c;中间有很多步骤&#xff0c;也就有很多出错的可能&#xff0c;因此会有很多不同的状态。 Pod的启动过程如下&#xff1a; 0&#xff09;controller-manager管理的…

qt-06QStackeddialog堆栈窗体应用

QStackeddialog堆栈窗体应用 QStackeddialog.hQStackeddialog.cppmain.cpp运行图 QStackeddialog.h #ifndef QSTACKEDDIALOG_H #define QSTACKEDDIALOG_H#include <QDialog> #include <QListWidget> #include <QStackedWidget> #include <QLabel>clas…

2024年【上海市安全员B证】模拟考试及上海市安全员B证证考试

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 上海市安全员B证模拟考试参考答案及上海市安全员B证考试试题解析是安全生产模拟考试一点通题库老师及上海市安全员B证操作证已考过的学员汇总&#xff0c;相对有效帮助上海市安全员B证证考试学员顺利通过考试。 1、【…