[中秋]宇宙第一 IDE Visual Studio 了解一下
2024-09-01 06:08:07
官网
https://visualstudio.microsoft.com/zh-hans/vs/
文档
https://docs.microsoft.com/zh-cn/visualstudio/designers/getting-started-with-wpf?view=vs-2019
第一个WPF桌面应用程序
安装Visual Studio
创建应用程序项目
工作区大概长这样子
写代码测试
编辑MainWindow.xaml(类似安卓开发的xml语言)
在Grid布局中添加
<TextBlock HorizontalAlignment="Left" Margin="252,47,0,0" TextWrapping="Wrap" Text="Select a message option and then choose the Display button." VerticalAlignment="Top"/>
<RadioButton x:Name="HelloButton" Content="Hello" IsChecked="True" HorizontalAlignment="Left" Margin="297,161,0,0" VerticalAlignment="Top" Height="30.24" Width="78.107"/>
<RadioButton x:Name="GoodbyeButton" Content="Goodbye" HorizontalAlignment="Left" Margin="488,161,0,0" VerticalAlignment="Top"/>
<Button Content="Display" Click="Button_Click_1" HorizontalAlignment="Left" Height="40.061" Margin="346.107,245.449,0,0" VerticalAlignment="Top" Width="201.689"/>
(可进行拖拽,放大缩小的图形化操作)
在MainWindow.xmal.ca添加按钮事件
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 WpfApp1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (HelloButton.IsChecked == true)
{
MessageBox.Show("Hello.","提示");
}
else if (GoodbyeButton.IsChecked == true)
{
MessageBox.Show("Goodbye.","提示");
}
}
}
}
其中Button_Click_1与之前xaml中Click对应
启动
小结
C# 开发的WPF对于非专业的开发者可以作为编写小工具的加持,毕竟现在PC桌面开发市场并不景气。
但是抛开市场经济的影响,C#加标记语言的开发模式和Android开发有着异曲同工之妙,殊途同归的设计除了适应场景上的不同,不知道是否会带来对于编程本身更加深刻的认知。
就像刚过中秋的月饼一样,如果摆在面前的有10种月饼,每种月饼有10个,但是只能吃十个,假设从来没有尝过月饼的你是否会每种都去尝试一下呢?
最新文章
- Git 安装
- ios xcode 下 报出 ”xx“is missing from working copy 的问题
- 哈夫曼树(Huffman Tree)与哈夫曼编码
- 【POJ】【2125】Destroying the Graph
- jquery中Live方法不可用,Jquery中Live方法失效
- List(列表)
- Html 小插件3
- 关于用PS改变图像颜色
- css 实现旋转八卦图
- String和StringBuffer的区别?
- 解决Android Studio编译后安装apk报错:Error while Installing APK
- iview form 表单的怪异小BUG
- 版本控制git第一篇
- Sony笔记本
- iOS:使用莱文斯坦距离算法计算两串字符串的相似度
- EasyUI表格DataGrid前端分页和后端分页的总结
- C#调用Delphi的dll之详解
- centos 安装 Vagrant
- POST 400 (BAD REQUEST)
- error MSB8031