LGX1972·大∵熊

微信号:lgx1972_9Y

博客生活 首页 新随笔 联系 聚合 管理
  96 Posts :: 1 Stories :: 619 Comments :: 1 Trackbacks

         XAML(可扩展应用程序标记语言),将给你构建豪华的应用程序界面提供快捷的途径,Windows Vista 将是该语言的用武之地。当然,你在Windows XP或Windows 2003 上同样可以实现。 以下是我安装了. Net Framework 3.0 Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP 。在Visual Studio 2005中编写的一个菜单。

CoolMeun.bmp

代码如下:

< Window  x:Class ="Window1"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    Title
="用XAML构建漂亮菜单"  Height ="354"  Width ="543"  Icon  ="e:\aivi\image\眼睛.ico"
    
>
       
< DockPanel  Name ="DockPanel1"  Width ="Auto"  Height ="Auto" >
        
< Menu  Name ="Menu1"  Width ="Auto"  Height ="24"  FontFamily ="宋体"   FontStyle ="Normal"  FontWeight ="Normal"  FontStretch ="Normal"  DockPanel.Dock ="Top" >
            
<!--  菜单条 -->
            
< Menu .Background >
                
< LinearGradientBrush  Opacity ="1"  StartPoint ="0,0"  EndPoint ="0,1" >
                    
< GradientStop  Color ="White"  Offset ="0"   />
                    
< GradientStop  Color ="DarkGreen"  Offset ="0.990476190476191"   />
                
</ LinearGradientBrush >
            
</ Menu.Background >
            
<!--  以上代码设置菜单条样式 -->
            
            
<!--  以下设置菜单项 -->
            
<!--  文件菜单 -->     
            
< MenuItem  Name ="MenuFile"  FontWeight ="Normal"  FontStretch ="Normal"  Selector.IsSelected ="False"  Header ="文件(_F)" >
                
< MenuItem  Name ="MenuOpen"  Selector.IsSelected ="False"  Header ="打开文件(_O)"   />
                
< MenuItem  Name ="MenuClose"  Selector.IsSelected ="False"  Header ="关闭文件(_C)"   />
                
< Separator />  
                
< MenuItem  Name ="MenuExit"  Selector.IsSelected ="False"  Header ="退出程序(_X)"   />
            
</ MenuItem >
            
<!--  编辑菜单 -->
            
< MenuItem  Name ="MenuEdit"  FontWeight ="Normal"  FontStretch ="Normal"  Selector.IsSelected ="False"  Header ="编辑(_E)" >
                
< MenuItem  Name ="MenuUndo"  Header ="撤消(_U)" >
                
</ MenuItem >
                
< Separator />
                    
< MenuItem  Name ="MenuCut"  Header ="剪切(_X)"   />
                    
< MenuItem  Name ="MenuCopy"  Header ="复制(_C)" ></ MenuItem >  
                    
< MenuItem  Name ="MenuPlaster"  Header ="粘贴(_P)"   />
                
< Separator />
                    
< MenuItem  Name ="MenuDelete"  Header ="删除(_D)"   />
            
</ MenuItem >
        
            
<!--  视图菜单 -->
            
< MenuItem  Name ="MenuView"  FontWeight ="Normal"  FontStretch ="Normal"  Selector.IsSelected ="False"  Header ="视图(_V)" >
            
<!--  项目菜单 -->
            
</ MenuItem >
            
< MenuItem  Name ="MenuProject"  FontWeight ="Nor mal"  FontStretch ="Normal"  Selector.IsSelected ="False"  Header ="项目(_P)" >
            
<!--  帮助菜单 -->
            
</ MenuItem >
            
< MenuItem  Name ="MenuHelp"  FontWeight ="Normal"  FontSt retch ="Normal"  Selector.IsSelected ="False"  Header ="帮助(_H)" >
            
</ MenuItem >
            
        
</ Menu >            
    
< Grid  Background ="Gray"   Grid.ColumnSpan ="3"  Grid.RowSpan ="2"  Height ="Auto"  Name ="Grid1"  Width ="Auto"   />
  
</ DockPanel >
</ Window >


总之,只要你学会XAML,你将随心所欲地编写漂亮的用户界面,我想这是我们都期待以久的。最重要的是在Visual Studio 2005开发环境下,用VB2005或C#你可以方便地把界面和相关的事件驱动程序结合起来,从而编写功能强大界面美观的应用程序。我也刚学习该语言不久,但立刻就被它的强大功能所吸引了。
posted on 2006-11-18 00:42 LGX1972·大∵熊 阅读(806) 评论(1)  编辑  收藏 所属分类: 编程相关

Feedback

# re: 用XAML构建漂亮菜单 2010-10-19 13:48 Ashen
这也叫漂亮的菜单条???我晕了···  回复  更多评论