به نام خدا سلام بر برنامه نویسان عزیز 😉 در این مطلب کد استفاده از Popup برای نمایش hyperlink با wpf و c#.net را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
خروجی این کد:
کد استفاده از Popup برای نمایش hyperlink با wpf و c#.net :
<Window x:Class="ClassicControls.PopupTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PopupTest" Height="300" Width="300">
<Grid Margin="10">
<TextBlock TextWrapping="Wrap">text
<Run TextDecorations="Underline" MouseEnter="run_MouseEnter">link</Run>
</TextBlock>
<Popup Name="popLink" StaysOpen="False" Placement="Mouse" MaxWidth="200" PopupAnimation="Slide" AllowsTransparency = "True">
<Border BorderBrush="Beige" BorderThickness="2" Background="White">
<TextBlock Margin="10" TextWrapping="Wrap" >
check out
<Hyperlink NavigateUri="http://java2s.com" Click="lnk_Click">java2s.com</Hyperlink>
</TextBlock>
</Border>
</Popup>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
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.Shapes;
using System.Diagnostics;
namespace ClassicControls
{
public partial class PopupTest : System.Windows.Window
{
public PopupTest()
{
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PopupTest" Height="300" Width="300">
<Grid Margin="10">
<TextBlock TextWrapping="Wrap">text
<Run TextDecorations="Underline" MouseEnter="run_MouseEnter">link</Run>
</TextBlock>
<Popup Name="popLink" StaysOpen="False" Placement="Mouse" MaxWidth="200" PopupAnimation="Slide" AllowsTransparency = "True">
<Border BorderBrush="Beige" BorderThickness="2" Background="White">
<TextBlock Margin="10" TextWrapping="Wrap" >
check out
<Hyperlink NavigateUri="http://java2s.com" Click="lnk_Click">java2s.com</Hyperlink>
</TextBlock>
</Border>
</Popup>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
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.Shapes;
using System.Diagnostics;
namespace ClassicControls
{
public partial class PopupTest : System.Windows.Window
{
public PopupTest()
{