目标:掌握C# 核心语法和面向对象编程,这是学习任何.NET UI框架的前提。
// 面向对象编程基础示例
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public void Introduce()
{
Console.WriteLine($"Hello, I'm {Name}, {Age} years old.");
}
}
// 继承和多态示例
public class Employee : Person
{
public string Department { get; set; }
public override void Introduce()
{
Console.WriteLine($"I'm {Name}, working in {Department} department.");
}
}
学习内容:
学习建议:此阶段专注于控制台应用程序练习,不涉及UI,打好编程基础。
目标:通过WinForms直观的特性快速上手桌面开发,理解事件驱动模型。

Visual Studio WinForms设计器界面
核心学习内容:
可视化设计器操作
常用控件掌握
// 事件处理示例
private void btnSubmit_Click(object sender, EventArgs e)
{
string name = txtName.Text;
if (!string.IsNullOrEmpty(name))
{
MessageBox.Show($"Hello, {name}!");
}
}
布局技巧
数据展示控件

WinForms实战项目截图
实战项目建议:
学习重点:多使用Visual Studio的拖拽设计器,理解事件如何驱动程序逻辑,体验快速开发。
目标:掌握WPF的核心思想,从声明式UI到数据驱动,学会MVVM模式。

XAML代码与设计视图对比
1. XAML与布局系统
<!-- XAML布局示例 -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock Text="欢迎使用WPF" FontSize="16" FontWeight="Bold"/>
<Button Content="刷新" Margin="10,0,0,0"/>
</StackPanel>
<ListView Grid.Row="1" ItemsSource="{Binding Items}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" Foreground="Blue"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
2. 数据绑定 - WPF的灵魂
// ViewModel实现数据绑定
public class MainViewModel : INotifyPropertyChanged
{
private string _userName;
public string UserName
{
get => _userName;
set
{
_userName = value;
OnPropertyChanged();
OnPropertyChanged(nameof(GreetingMessage));
}
}
public string GreetingMessage => $"Hello, {UserName}!";
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

MVVM架构示意图
3. MVVM模式深入
// ICommand实现
public class RelayCommand : ICommand
{
private readonly Action _execute;
private readonly Func<bool> _canExecute;
public RelayCommand(Action execute, Func<bool> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter) => _canExecute?.Invoke() ?? true;
public void Execute(object parameter) => _execute();
public event EventHandler CanExecuteChanged;
}
4. 样式与模板
<!-- 自定义Button样式 -->
<Style x:Key="ModernButton" TargetType="Button">
<Setter Property="Background" Value="#007ACC"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="4" Padding="10,5">
<ContentPresenter HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
实战项目建议:
学习重点:摆脱WinForms的事件驱动思维,建立数据驱动思想,掌握MVVM架构模式。
目标:根据发展方向深化技能,了解现代桌面开发生态。
深化方向:
性能优化
第三方控件库集成
现代开发实践
// 依赖注入集成
public partial classApp : Application
{
protected override void OnStartup(StartupEventArgs e)
{
var services = new ServiceCollection();
services.AddTransient<IMainViewModel, MainViewModel>();
services.AddTransient<MainWindow>();
var provider = services.BuildServiceProvider();
var mainWindow = provider.GetService<MainWindow>();
mainWindow.Show();
}
}
现代化改造

技术选择决策流程图
框架选择总结:
应用场景 | 推荐框架 | 关键理由 |
|---|---|---|
企业级复杂应用 | WPF | 数据绑定强大,MVVM架构,长期可维护性 |
内部工具/原型 | WinForms | 开发速度快,学习成本低 |
维护现有系统 | 对应框架 | 保持技术栈一致性 |
高UI设计要求 | WPF | 矢量图形,样式模板,动画支持 |
传统Windows风格 | WinForms | 原生Windows控件体验 |
重要提示:网盘链接有时效性,如果失效请通过官方渠道或搜索引擎查找最新资源。
Winform&WPF学习视频学习寄语:WinForms让你快速上手桌面开发,WPF带你进入现代化UI开发的世界。两者都是.NET生态中的重要技能,掌握它们让你在桌面开发领域游刃有余。从传统到现代,从简单到复杂,这条学习路线将引导你成长为全面的.NET桌面开发工程师!