简体   繁体   English

将XAML.CS嵌入到Powershell WPF工具中

[英]Embed XAML.CS into Powershell WPF Tool

Im currently working on a little tool that has multiple tabs, one of these tabs is a Profile Reset Tool. 我目前正在使用一个带有多个标签的小工具,其中一个标签是配置文件重置工具。 This is the current GUI 这是当前的GUI 图形用户界面

The powershell fully functions as I want it to however I do not have suitable XAML Code to handle Click Events. Powershell完全可以按我希望的方式运行,但是我没有合适的XAML代码来处理Click事件。 I know I can do this easily through the XAML.CS in C# however do not know how I would transfer that code over to the PS Script 我知道我可以通过C#中的XAML.CS轻松完成此操作,但是不知道如何将代码转移到PS脚本中

The best solution would be to handle Click Events directly through the XAML but i'm not too sure what I would modify 最好的解决方案是直接通过XAML处理Click Events,但我不太确定该修改什么

Restart Machine 重启机器

<Button x:Name="NTRelease" Content="1) Restart Machine" HorizontalAlignment="Left" Margin="386,164,0,0" VerticalAlignment="Top" Width="180" Height="23" IsEnabled="{Binding ElementName=ProfileSelect, Path=Text.Length, Mode=OneWay}" Click="NTRelease_Click"/>

Get Drives & Printers 获取驱动器和打印机

<Button x:Name="GetInfo" Content="2) Get Drives &amp; Printers" HorizontalAlignment="Left" Margin="386,192,0,0" VerticalAlignment="Top" Width="180" Height="23" IsEnabled="False"/>

Thanks 谢谢

Disables a Button 禁用按钮

$WPFButton.Add_Click({
$WPF.IsEnabled = $False
)}

Enables a button 启用按钮

$WPFButton.Add_Click({
$WPF.IsEnabled = $True
)}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM