首页 > 其他 > 详细

解开XAML的邪恶面纱

时间:2018-07-21 13:31:30      阅读:122      评论:0      收藏:0      [点我收藏+]

什么是XAML,首先我们看下它的外观

<Window x:Class="Blend_WPF.WindowStyle"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Blend_WPF"  mc:Ignorable="d" >
    <Grid>
        <Button Content="Button" HorizontalAlignment="Left" Margin="271,203.5,0,0" VerticalAlignment="Top" Width="75"/>
    </Grid>
</Window>

外一层是Window,进一层是Grid,再进一层是Button,感觉是和Web静态网页一样的写法,除了前面多了一些自己暂时还看不懂的xmlns

其实并不是,XAML官方定义是:一种相对简单、通用的声明式编程语言。所以别看这标签是这样,其实一个个对象(经过XAML编译器和运行时解析器解释后)

比如上面的一个Button

        <Button Content="Button" />

解开面纱,看本质

        Button b=new Button();

        b.Content="Button";

WPF通过XAML语言实现界面与逻辑分离,在一定程度上方便了开发人员和设计人员的分工协作,取得了不错的效果

 

解开XAML的邪恶面纱

原文:https://www.cnblogs.com/Kevinsh-Lee/p/9345733.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!