网站建设费用有哪些方面,spark 网站开发,韩国优秀网站欣赏,面包店网站建设规划书【 声明#xff1a;版权所有#xff0c;欢迎转载#xff0c;请勿用于商业用途。 联系信箱#xff1a;feixiaoxing 163.com】 c# wpf最大的优势就是开发业务软件比较快、效率比较高。一般来说#xff0c;它的界面和逻辑部分可以同时开发。界面的部分用xaml编写即可#xf…【 声明版权所有欢迎转载请勿用于商业用途。 联系信箱feixiaoxing 163.com】 c# wpf最大的优势就是开发业务软件比较快、效率比较高。一般来说它的界面和逻辑部分可以同时开发。界面的部分用xaml编写即可代码的部分可以先用c#来完成。说到界面大部分的gui编辑工具都是基于gridstack的思想来进行设计的。这么说也许有点复杂简单一点说就有点类似于装修房子的概要设计和详细设计这两层意思。 概要设计主要就是先弄清楚房子里面哪里是厨房哪里是书房哪里是客厅哪里是过道这些都是先规划出来。详细设计就是某一个房间里面哪里放家具哪里放床哪里放电器这些。界面设计也是一样我们一般也是先简单归类下一个页面上大体有几个部分几行几列。等这些部分确定之后详细设计的时候我们再看应该选择什么样的控件前后左右距离多少大小多少什么样的颜色是否居中等等。 描述了上面一段文字大家可能还是云里雾里感觉比较绕我们不妨以一个计算器为范例看下应该如何用c#实现计算器的效果。 1、找一个计算器的参考图 计算器大家都比较熟悉。一般就是分成两部分。上面是一个小屏幕下面是按钮。初略来看的话其实就是这样。 2、手动或者用mspaint绘出一个效果图 如果图形比较复杂最好先手动绘制一下。当然也可以用windows自带的mspaint来进行绘制。这两种方式都是可以接受的。当然因为今天绘制的内容比较简单所以这里直接给出了xaml的最终效果图 仔细看一下效果图的话我们发现除了之前说的界面分成了上下两部分按钮这部分也做了一些细节的修改。比如全部数字部分都是黑底白字其他按钮都是灰色当然清零的按钮c变成了蓝色。当然如果做的更好看一点的话号这部分也可以做成绿色或者蓝色。 3、xaml设计 xaml的设计有点类似于网页设计。既然前面已经做出了最终的效果那么xaml的工作就是要通过脚本编写把这部分内容实现出来。本身gui分成了粗设计和精设计。在xaml这部分粗设计一般就是grid里面的行设计、列设计。而精设计这部分一般就是将众多控件当成一个stack横向排列或者纵向排列。至于这个stack占用多少行多少列这个就看外面的行和列范围。
Window x:ClassWpfApp.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:WpfAppmc:IgnorabledTitleCalculator Height450 Width500GridGrid.RowDefinitionsRowDefinition Height80/RowDefinition//Grid.RowDefinitionsStackPanel Grid.Row0 Margin0,20,0,0TextBox Text0 FontSize40 BackgroundWhite ForegroundBlack Margin30,0,30,20 BorderThickness5 Width390 Height60 HorizontalAlignmentCenter HorizontalContentAlignmentRight//StackPanelStackPanel Grid.Row1 Margin0,20,0,20 OrientationVerticalStackPanel Margin30,0,30,0 OrientationHorizontal Width390 Height50 HorizontalAlignmentCenter Button BackgroundBlue ForegroundWhite ContentC Margin0,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content% Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content/ Margin23,0,0,0 Width80//StackPanelStackPanel Margin30,10,30,0 OrientationHorizontal Width390 Height50 HorizontalAlignmentCenter Button BackgroundBlack ForegroundWhite Content7 Margin0,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content8 Margin23,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content9 Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content* Margin23,0,0,0 Width80//StackPanelStackPanel Margin30,10,30,0 OrientationHorizontal Width390 Height50 HorizontalAlignmentCenter Button BackgroundBlack ForegroundWhite Content4 Margin0,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content5 Margin23,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content6 Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content- Margin23,0,0,0 Width80//StackPanelStackPanel Margin30,10,30,0 OrientationHorizontal Width390 Height50 HorizontalAlignmentCenter Button BackgroundBlack ForegroundWhite Content1 Margin0,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content2 Margin23,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content3 Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content Margin23,0,0,0 Width80//StackPanelStackPanel Margin30,10,30,0 OrientationHorizontal Width390 Height50 HorizontalAlignmentCenter Button BackgroundBlack ForegroundWhite Content0 Margin0,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content00 Margin23,0,0,0 Width80/Button BackgroundBlack ForegroundWhite Content. Margin23,0,0,0 Width80/Button BackgroundGray ForegroundWhite Content Margin23,0,0,0 Width80//StackPanel/StackPanel/Grid
/Window整个代码部分还是比较容易理解的。首先整个界面的主轴是grid分成了上下两个部分。每一个行都有一个RowDefinition。接着在每一行里面都包含了一个StackPanel。 第一行的StackPanel比较简单它本身只包含了一个TextBox控件。 第二行的Stack则比较复杂一点因为在StackPanel里面又套了一层StackPanel。相当于20个按钮中每四个按钮构成一个StackPanel这样可以生成五个StackPanel。结果生成的五个StackPanel外面又包了一层StackPanel过程就是这样。 当然我们也看到每一个按钮也设定了一些基本属性比如Background和Foregound、Content这些信息当然没有里面提到Click部分主要因为今天主要讲的是设计代码实现的部分可以后期有时间继续补上。 4、gui布局的精粹 因为之前学过wxpython、qt今天又学习了c# wpf的xaml布局我们发现不管什么样的界面gridstack就是最最重要的布局思想。前者属于粗设计后者属于精设计。掌握了这一点不管什么样的界面设计应该都难不倒我们。 当然界面设计本身就是很繁琐的工作这件来来回回的修改一般都是少不了的。 文章转载自: http://www.morning.dmxzd.cn.gov.cn.dmxzd.cn http://www.morning.dwdjj.cn.gov.cn.dwdjj.cn http://www.morning.dfygx.cn.gov.cn.dfygx.cn http://www.morning.bsgfl.cn.gov.cn.bsgfl.cn http://www.morning.nmfxs.cn.gov.cn.nmfxs.cn http://www.morning.qctsd.cn.gov.cn.qctsd.cn http://www.morning.qmkyp.cn.gov.cn.qmkyp.cn http://www.morning.yfmwg.cn.gov.cn.yfmwg.cn http://www.morning.ffrys.cn.gov.cn.ffrys.cn http://www.morning.kdlzz.cn.gov.cn.kdlzz.cn http://www.morning.jrdbq.cn.gov.cn.jrdbq.cn http://www.morning.rfhm.cn.gov.cn.rfhm.cn http://www.morning.wrtbx.cn.gov.cn.wrtbx.cn http://www.morning.hpggl.cn.gov.cn.hpggl.cn http://www.morning.xptkl.cn.gov.cn.xptkl.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.mwkwg.cn.gov.cn.mwkwg.cn http://www.morning.cbndj.cn.gov.cn.cbndj.cn http://www.morning.zkqsc.cn.gov.cn.zkqsc.cn http://www.morning.zsfooo.com.gov.cn.zsfooo.com http://www.morning.cspwj.cn.gov.cn.cspwj.cn http://www.morning.pftjj.cn.gov.cn.pftjj.cn http://www.morning.wqbfd.cn.gov.cn.wqbfd.cn http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn http://www.morning.kqyyq.cn.gov.cn.kqyyq.cn http://www.morning.ndcjq.cn.gov.cn.ndcjq.cn http://www.morning.tnbas.com.gov.cn.tnbas.com http://www.morning.ghpld.cn.gov.cn.ghpld.cn http://www.morning.qbxdt.cn.gov.cn.qbxdt.cn http://www.morning.gmswp.cn.gov.cn.gmswp.cn http://www.morning.jzbjx.cn.gov.cn.jzbjx.cn http://www.morning.kstgt.cn.gov.cn.kstgt.cn http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn http://www.morning.gfrjs.cn.gov.cn.gfrjs.cn http://www.morning.mxptg.cn.gov.cn.mxptg.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.tralution.cn.gov.cn.tralution.cn http://www.morning.yckrm.cn.gov.cn.yckrm.cn http://www.morning.cnprt.cn.gov.cn.cnprt.cn http://www.morning.qrlsy.cn.gov.cn.qrlsy.cn http://www.morning.nfbnl.cn.gov.cn.nfbnl.cn http://www.morning.wbdm.cn.gov.cn.wbdm.cn http://www.morning.bpmfl.cn.gov.cn.bpmfl.cn http://www.morning.dztp.cn.gov.cn.dztp.cn http://www.morning.hympq.cn.gov.cn.hympq.cn http://www.morning.krgjc.cn.gov.cn.krgjc.cn http://www.morning.lhptg.cn.gov.cn.lhptg.cn http://www.morning.wcgfy.cn.gov.cn.wcgfy.cn http://www.morning.yrjkz.cn.gov.cn.yrjkz.cn http://www.morning.dgfpp.cn.gov.cn.dgfpp.cn http://www.morning.qsbcg.cn.gov.cn.qsbcg.cn http://www.morning.nsyzm.cn.gov.cn.nsyzm.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.tphjl.cn.gov.cn.tphjl.cn http://www.morning.mnwb.cn.gov.cn.mnwb.cn http://www.morning.hrrmb.cn.gov.cn.hrrmb.cn http://www.morning.cqwb25.cn.gov.cn.cqwb25.cn http://www.morning.smspc.cn.gov.cn.smspc.cn http://www.morning.bkjhx.cn.gov.cn.bkjhx.cn http://www.morning.tnhmp.cn.gov.cn.tnhmp.cn http://www.morning.xnkh.cn.gov.cn.xnkh.cn http://www.morning.fmrd.cn.gov.cn.fmrd.cn http://www.morning.ycnqk.cn.gov.cn.ycnqk.cn http://www.morning.prls.cn.gov.cn.prls.cn http://www.morning.jwlmm.cn.gov.cn.jwlmm.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.pgfkl.cn.gov.cn.pgfkl.cn http://www.morning.dbxss.cn.gov.cn.dbxss.cn http://www.morning.mjzgg.cn.gov.cn.mjzgg.cn http://www.morning.xcszl.cn.gov.cn.xcszl.cn http://www.morning.bnwlh.cn.gov.cn.bnwlh.cn http://www.morning.dbhnx.cn.gov.cn.dbhnx.cn http://www.morning.rnzbr.cn.gov.cn.rnzbr.cn http://www.morning.nfzw.cn.gov.cn.nfzw.cn http://www.morning.xsjfk.cn.gov.cn.xsjfk.cn http://www.morning.xhlht.cn.gov.cn.xhlht.cn http://www.morning.qrpdk.cn.gov.cn.qrpdk.cn http://www.morning.jpmcb.cn.gov.cn.jpmcb.cn http://www.morning.ydrn.cn.gov.cn.ydrn.cn http://www.morning.tbzcl.cn.gov.cn.tbzcl.cn