效果分析:当鼠标左键单击QQ的昵称时,会弹出另一个关于个人信息的窗口。

此处用到的是Popup。

设置鼠标触发Popup事件,该事件触发会跳转到另一个自定义窗口。

前台代码:

<Button Content="邓不利东" FontSize="24" FontStyle="Normal" Foreground="Black" Background="Transparent" BorderBrush="Transparent"
                    Cursor="Hand" Click="Popup_CP_Click"/>

后台Popup_CP_Click的事件触发:

private void Popup_CP_Click(object sender, RoutedEventArgs e)   
        {
            MyProfile myprofile = new MyProfile();
            myprofile.ShowDialog();
        }

触发事件中MyProfile myprofile = new MyProfile(); 是新建一个MyProfile的窗口,因此,我们新建窗口的时候,将 Title 设为 MyProfile 即可。

如下:

<Window x:Class="QQ_presentation.MyProfile"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MyProfile" Height="700" Width="560"
        ResizeMode="NoResize">

 

WPF—QQ界面(四):单击QQ昵称弹出个人简介窗口的效果实现

此时就能将主窗口与自定义窗口建立连接了,用Popup弹出自定义窗口。

最终效果图如下:

WPF—QQ界面(四):单击QQ昵称弹出个人简介窗口的效果实现

右图即为Popup出的新窗口。

 

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2021-11-29
  • 2021-09-09
  • 2021-06-14
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2021-12-19
  • 2022-12-23
  • 2021-09-13
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案