当前位置: 移动技术网 > IT编程>开发语言>c# > [中秋]宇宙第一 IDE Visual Studio 了解一下

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

2019年09月17日  | 移动技术网IT编程  | 我要评论
但是抛开市场经济的影响,C#加标记语言的开发模式和Android开发有着异曲同工之妙,殊途同归的设计除了适应场景上的不同,不知道是否会带来对于编程本身更加深刻的认知。 ...

官网

1568433673990

文档

1568433803725

1568433863402

第一个wpf桌面应用程序

安装visual studio

1568433946342

创建应用程序项目

1568434008402

1568434033424

工作区大概长这样子

1568434106232

写代码测试

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

    1568434222809

在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"/>

1568434306402

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

  • 在mainwindow.xmal.ca添加按钮事件

    1568434363795

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

  • 启动

    1568434520979

1568434541345

1568434549292


小结

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

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

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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网