一、控件使用上
1.button
winform中button显示的内容可以通过button.Text来get、set
button.Text = "连接";
string str = button.Text;
WPF中改成了button.Content,并且Content的get返回值类型为object
button.Content = "连接";
string str = button.Content.ToString();
二、事件调用上
1.winform存在"ShowForm.designer.cs"文件,如下图所示
自己写的窗口关闭的时间函数,需在该文件内手动添加调用
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowForm_Closed);
2.WPF没有上面的文件,取而代之的是“MainWindow.g.i.cs”,下文是对应的代码,不过该文件的内容是自动生成的。
#line 9 "..\..\MainWindow.xaml"
((Skip_Hole.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);
自己要添加或者修改的话,需要在“MainWindow.xaml”上修改,如下
<Window x:Class="Skip_Hole.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Skip_Hole"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525"
Closing="Window_Closing">
在Window的属性里增加“Closing="Window_Closing"”