前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[中秋]宇宙第一 IDE Visual Studio 了解一下

[中秋]宇宙第一 IDE Visual Studio 了解一下

作者头像
Noneplus
发布2019-09-24 16:18:29
9400
发布2019-09-24 16:18:29
举报
文章被收录于专栏:开发笔记开发笔记

官网

https://visualstudio.microsoft.com/zh-hans/vs/

1568433673990
1568433673990

文档

https://docs.microsoft.com/zh-cn/visualstudio/designers/getting-started-with-wpf?view=vs-2019

1568433803725
1568433803725

https://docs.microsoft.com/zh-cn/dotnet/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application

1568433863402
1568433863402

第一个WPF桌面应用程序

安装Visual Studio

1568433946342
1568433946342

创建应用程序项目

1568434008402
1568434008402
1568434033424
1568434033424

工作区大概长这样子

1568434106232
1568434106232

写代码测试

  • 编辑MainWindow.xaml(类似安卓开发的xml语言)
1568434222809
1568434222809

在Grid布局中添加

代码语言:javascript
复制
<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"/>
1568434306402
1568434306402

(可进行拖拽,放大缩小的图形化操作)

  • 在MainWindow.xmal.ca添加按钮事件
1568434363795
1568434363795
代码语言:javascript
复制
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对应

1568434433888
1568434433888
  • 启动
1568434520979
1568434520979
1568434541345
1568434541345
1568434549292
1568434549292

小结

C# 开发的WPF对于非专业的开发者可以作为编写小工具的加持,毕竟现在PC桌面开发市场并不景气。

但是抛开市场经济的影响,C#加标记语言的开发模式和Android开发有着异曲同工之妙,殊途同归的设计除了适应场景上的不同,不知道是否会带来对于编程本身更加深刻的认知。

就像刚过中秋的月饼一样,如果摆在面前的有10种月饼,每种月饼有10个,但是只能吃十个,假设从来没有尝过月饼的你是否会每种都去尝试一下呢?

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 官网
  • 文档
  • 第一个WPF桌面应用程序
    • 安装Visual Studio
      • 创建应用程序项目
        • 写代码测试
          • 小结
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档