欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

wpf学习笔记---初识xaml标签语言

发布时间:2025/7/25 编程问答 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 wpf学习笔记---初识xaml标签语言 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
最近下载了windows sdk,也来凑下热闹学学新技术。顺便也简单的记录下学习过程.此非教程.由于刚接触,一切皆以实用为主.先了解其特性为好.


一.xaml的结构为xml形式组成,与flex中的标签语言很相似.这个是比html好的地方,不写废话了.写些实用的东西

二.XAML基本语法

1.根元素必须声明命名空间,如

<Page 
  
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml">
  
</Page>


2.声明XAML控件(标签)

<Button Content="Click Me"/>或<Button>Click Me</Button>

3.定义标签属性

<Button Background="Blue" Foreground="Red" Content="This is a button"/>


<Button>
  
<Button.Background>
    
<SolidColorBrush Color="Blue"/>
  
</Button.Background>
  
<Button.Foreground>
    
<SolidColorBrush Color="Red"/>
  
</Button.Foreground>
  
<Button.Content>
    This is a button
  
</Button.Content>
</Button>


4.触发事件

<Button Background="Blue" Click="OnClick" Content="This is a button"/>

void OnClick(object sender, RoutedEventArgs e)
{

   }



5.页面跳转

<Hyperlink NavigateUri="UriOfPageToNavigateTo.xaml">Navigate</Hyperlink>   第一篇还不知道写些什么,先就这样好了

转载于:https://www.cnblogs.com/Clingingboy/archive/2007/03/04/663273.html

总结

以上是生活随笔为你收集整理的wpf学习笔记---初识xaml标签语言的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。