feat: WPF控件-6-工具提示

This commit is contained in:
Bunny 2025-01-04 11:13:19 +08:00
parent ed70a4afcc
commit 2cb82f97b7
8 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<Application x:Class="WPF控件_6_工具提示.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF控件_6_工具提示"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace WPF控件_6_工具提示;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,56 @@
<Window x:Class="WPF控件_6_工具提示.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"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<StackPanel HorizontalAlignment="Left">
<!-- 鼠标放上去会有提示 -->
<Button Padding="3" ToolTip="呵呵">嘻嘻嘻</Button>
<!-- 显示图片背景颜色 -->
<Button Padding="3">
<Button.ToolTip>
<StackPanel>
<TextBlock Margin="3">图片提示</TextBlock>
<Image Source="public/9b3412d16970a7749cf6cf4d6ebf5b86.jpg" />
<TextBlock Margin="3">图片提示</TextBlock>
</StackPanel>
</Button.ToolTip>
<Button.Content>显示图片背景颜色</Button.Content>
</Button>
<!-- 按钮提示设置背景颜色 -->
<Button Padding="3">
<Button.ToolTip>
<ToolTip Background="#60AA4030" Foreground="White" HasDropShadow="False">
<StackPanel>
<TextBlock Margin="3">图片提示</TextBlock>
<Image Source="public/9b3412d16970a7749cf6cf4d6ebf5b86.jpg" />
<TextBlock Margin="3">图片提示</TextBlock>
</StackPanel>
</ToolTip>
</Button.ToolTip>
<Button.Content>按钮提示设置背景颜色</Button.Content>
</Button>
<Button Padding="3">
<Button.ToolTip>
<!-- Placement 位于哪里显示 -->
<ToolTip Background="Aqua" Foreground="White" HasDropShadow="True" Placement="Absolute">
<StackPanel>
<TextBlock Margin="3">图片提示</TextBlock>
<Image Source="public/9b3412d16970a7749cf6cf4d6ebf5b86.jpg" />
<TextBlock Margin="3">图片提示</TextBlock>
</StackPanel>
</ToolTip>
</Button.ToolTip>
<Button.Content>按钮提示设置背景颜色</Button.Content>
</Button>
</StackPanel>
</Window>

View File

@ -0,0 +1,23 @@
using System.Text;
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控件_6_工具提示;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>WPF控件_6_工具提示</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="public\9b3412d16970a7749cf6cf4d6ebf5b86.jpg"/>
<Resource Include="public\9b3412d16970a7749cf6cf4d6ebf5b86.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-4-标签", "WPF
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-5-RadioButton", "WPF控件-5-RadioButton\WPF控件-5-RadioButton.csproj", "{C3961D75-D2BF-4979-B985-1FD652CDFC0C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-5-RadioButton", "WPF控件-5-RadioButton\WPF控件-5-RadioButton.csproj", "{C3961D75-D2BF-4979-B985-1FD652CDFC0C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-6-工具提示", "WPF控件-6-工具提示\WPF控件-6-工具提示.csproj", "{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -36,5 +38,9 @@ Global
{C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU {C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU {C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Release|Any CPU.Build.0 = Release|Any CPU {C3961D75-D2BF-4979-B985-1FD652CDFC0C}.Release|Any CPU.Build.0 = Release|Any CPU
{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal