WPF多窗口

Mainwindow.xaml

<Window x:Class="WPF多窗口.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="主窗口" Height="388.889" Width="581.322">
    <Grid Margin="0,0,2,-4">
        <Button x:Name="ButtonNew" Content="显示新窗口" HorizontalAlignment="Left" Margin="336,104,0,0" VerticalAlignment="Top" Width="170" Click="ButtonNew_Click"/>
        <Button x:Name="ButtonClose" Content="关闭全部附属窗口" HorizontalAlignment="Left" Margin="336,175,0,0" VerticalAlignment="Top" Width="170" Click="ButtonClose_Click"/>
        <Button x:Name="ButtonExit" Content="结束程序运行" HorizontalAlignment="Left" Margin="336,245,0,0" VerticalAlignment="Top" Width="170" Click="ButtonExit_Click"/>

    </Grid>
</Window>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
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多窗口
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private int windowCount;
        private int left;
        private int top;
        public MainWindow()
        {
            InitializeComponent();
            windowCount = 0;
            left = 300;
            top = 300;
        }

        private void ButtonNew_Click(object sender, RoutedEventArgs e)
        {
            Window win = new Window();
            windowCount++; left += 30; top += 30;
            win.Title = "附属窗口" + windowCount.ToString();
            win.Height = 200; win.Width = 328;
            win.Left = left; win.Top = top;
            win.Owner = this;
            win.ShowActivated = false;
            win.Show();
        }

        private void ButtonClose_Click(object sender, RoutedEventArgs e)
        {
            foreach (Window win in this.OwnedWindows)
                win.Close();
        }

        private void ButtonExit_Click(object sender, RoutedEventArgs e)
        {
            App.Current.Shutdown();
        }
    }
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WPF是一种用于开发Windows应用程序的技术框架。迅雷窗口样式是指在WPF应用程序中使用类似于迅雷软件的窗口样式。 迅雷窗口样式通常包括以下几个特点: 1. 边框和标题栏:迅雷窗口样式通常具有特殊的边框和标题栏设计,可以给用户带来独特的视觉体验。边框和标题栏可以进行自定义,例如可以设置不规则的边框样式,或者给标题栏添加自定义的图标和按钮。 2. 透明效果:迅雷窗口样式通常采用透明效果,可以显示出背后的桌面或其他窗口内容。这样可以增加应用程序的时尚感和科技感。 3. 强调视图:迅雷窗口样式通常会对某些重要的视图元素进行强调,例如下载进度、操作按钮等。这样可以提升用户对这些重要信息的注意力,使其更易于操作。 4. 动画效果:迅雷窗口样式通常会使用各种动画效果来增加交互的流畅性和美观性,例如弹出菜单、窗口缩放等。这样可以提升用户体验,使应用程序更加生动有趣。 开发WPF应用程序时,可以使用XAML语言来定义窗口样式。通过设置窗口的样式属性和使用自定义的控件模板,可以实现类似迅雷窗口样式的效果。同时,WPF还提供了丰富的视觉效果和动画功能,可以进一步增强迅雷窗口样式的效果。 总之,迅雷窗口样式是一种在WPF应用程序中使用类似于迅雷软件的窗口外观和交互效果的设计风格。通过合理运用WPF技术,可以实现这种样式,并提升用户体验和应用程序的吸引力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值