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

本文介绍了一位新手开发者初次接触Windows Presentation Foundation (WPF) 和 Extensible Application Markup Language (XAML) 的经历,主要介绍了XAML的基本语法,包括命名空间声明、控件定义、属性设置、事件触发及页面跳转等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      最近下载了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>
 
第一篇还不知道写些什么,先就这样好了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值