feat: WPF控件-7-Popup

This commit is contained in:
Bunny 2025-01-04 11:28:46 +08:00
parent 2cb82f97b7
commit ad73569c67
7 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<Application x:Class="WPF控件_7_Popup.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF控件_7_Popup"
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控件_7_Popup;
/// <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,23 @@
<Window x:Class="WPF控件_7_Popup.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="WPF控件_7_Popup" Height="450" Width="800">
<StackPanel>
<TextBlock TextWrapping="Wrap">
那年国破,皇上自缢,将军带着妻子出逃。行至十里镇,和妻子被伏兵暗算,双双中箭。香消玉殒前,妻子爬向他低语:“若来世你我皆为人,再做夫妻。若只你为人,我便做那每天陪你之物。”说罢气绝。“后来呢?”小和尚睁着眼问道。方丈默默地转着手串上那唯一的一颗念珠,青灯幽暗,不言不语。
<Run Foreground="Red" TextDecorations="UnderLine" MouseEnter="ContentElement_OnMouseEnter">这个有提示的</Run>
</TextBlock>
<Popup Name="PopupLink" StaysOpen="False" Placement="Mouse" MaxWidth="200" PopupAnimation="Slide" AllowsTransparency="True">
<Border BorderBrush="Beige" BorderThickness="2" Background="White">
<TextBlock Margin="10" TextWrapping="Wrap">
小兔子画面生成
<Hyperlink NavigateUri="https://www.baidu.com/" Click="Hyperlink_OnClick">打开</Hyperlink>
</TextBlock>
</Border>
</Popup>
</StackPanel>
</Window>

View File

@ -0,0 +1,28 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
namespace WPF控件_7_Popup;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ContentElement_OnMouseEnter(object sender, MouseEventArgs e)
{
PopupLink.IsOpen = true;
}
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
{
var hyperlink = (Hyperlink)sender;
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri) { UseShellExecute = true });
}
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>WPF控件_7_Popup</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

View File

@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-5-RadioButton", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-6-工具提示", "WPF控件-6-工具提示\WPF控件-6-工具提示.csproj", "{C7D48A55-D0A4-4C5C-BC04-FD9F0F39803F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-7-Popup", "WPF控件-7-Popup\WPF控件-7-Popup.csproj", "{1C272D2C-BAC3-4D94-9491-E05B688B9A98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -42,5 +44,9 @@ Global
{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
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal