wpf学习笔记---Canvas

时间:2021-09-16 20:29:22
        继续发. Canvas为容器控件,用于定位

1.基本应用

wpf学习笔记---Canvas   < Border  HorizontalAlignment ="Left"  VerticalAlignment ="Top"  BorderBrush ="Black"  BorderThickness ="2" >
wpf学习笔记---Canvas    
< Canvas  Background ="LightBlue"  Width ="400"  Height ="400" >
wpf学习笔记---Canvas      
< Button  Canvas.Top ="50" > Canvas.Top="50" </ Button >
wpf学习笔记---Canvas      
< Button  Canvas.Bottom ="50" > Canvas.Bottom="50" </ Button >
wpf学习笔记---Canvas      
< Button  Canvas.Left ="50" > Canvas.Left="50" </ Button >
wpf学习笔记---Canvas      
< Button  Canvas.Right ="50" > Canvas.Right="50" </ Button >
wpf学习笔记---Canvas    
</ Canvas >
wpf学习笔记---Canvas  
</ Border >     

wpf学习笔记---Canvas

2.当同时设置left和right,top和bottom,以left和top为准

3.重叠深度设置

wpf学习笔记---Canvas< Canvas >
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="3"  Width ="100"  Height ="100"  Canvas.Top ="100"  Canvas.Left ="100"  Fill ="blue" />
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="1"  Width ="100"  Height ="100"  Canvas.Top ="150"  Canvas.Left ="150"  Fill ="yellow" />
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="2"  Width ="100"  Height ="100"  Canvas.Top ="200"  Canvas.Left ="200"  Fill ="green" />
wpf学习笔记---Canvas
wpf学习笔记---Canvas    
<!--  Reverse the order to illustrate z-index property  -->
wpf学习笔记---Canvas
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="1"  Width ="100"  Height ="100"  Canvas.Top ="300"  Canvas.Left ="200"  Fill ="green" />
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="3"  Width ="100"  Height ="100"  Canvas.Top ="350"  Canvas.Left ="150"  Fill ="yellow" />
wpf学习笔记---Canvas    
< Rectangle  Canvas.ZIndex ="2"  Width ="100"  Height ="100"  Canvas.Top ="400"  Canvas.Left ="100"  Fill ="blue" />
wpf学习笔记---Canvas  
</ Canvas >

wpf学习笔记---Canvas