手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell使用WPF技术实现弹窗提示实例
Powershell使用WPF技术实现弹窗提示实例
摘要:WPF(WindowsPresentationFoundation)技术能让你创建窗口和对话框。它的优势是在窗体设计时能与代码分开。这里有个...

WPF (Windows Presentation Foundation) 技术能让你创建窗口和对话框。它的优势是在窗体设计时能与代码分开。

这里有个简单的显示弹出消息练习。这个消息是定义在XAML代码中它的实现类似HTML(但是请区分大小写)。你能轻松的调整字体大小,内容,颜色等等。不需要嵌入任何代码。

复制代码 代码如下:

$xaml = @"

<Window

xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>

<Border BorderThickness="20" BorderBrush="Yellow" CornerRadius="9" Background='Red'>

<StackPanel>

<Label FontSize="50" FontFamily='Stencil' Background='Red' Foreground='White' BorderThickness='0'>

System will be rebooted in 15 minutes!

</Label>

<Label HorizontalAlignment="Center" FontSize="15" FontFamily='Consolas' Background='Red' Foreground='White' BorderThickness='0'>

Worried about losing data? Talk to your friendly help desk representative and freely share your concerns!

</Label>

</StackPanel>

</Border>

</Window>

"@

$reader = [System.XML.XMLReader]::Create([System.IO.StringReader] $xaml)

$window = [System.Windows.Markup.XAMLReader]::Load($reader)

$Window.AllowsTransparency = $True

$window.SizeToContent = 'WidthAndHeight'

$window.ResizeMode = 'NoResize'

$Window.Opacity = .7

$window.Topmost = $true

$window.WindowStartupLocation = 'CenterScreen'

$window.WindowStyle = 'None'

# show message for 5 seconds:

$null = $window.Show()

Start-Sleep -Seconds 5

$window.Close()

【Powershell使用WPF技术实现弹窗提示实例】相关文章:

Windows Powershell创建对象

PowerShell实现在字符串中查找大写字母

Powershell小技巧之判断是否包涵大小写

PowerShell函数参数指定数据类型实例

Powershell小技巧之找出脚本中的错误

PowerShell中使用Get-Alias命令获取cmdlet别名例子

Windows Powershell ForEach-Object 循环

PowerShell快速创建一个指定大小文件的实例分享

powershell操作word详解

PowerShell使用枚举变量定义带智能提示功能的函数参数

精品推荐
分类导航