WPF笔记(1.10 绘图)——Hello,WPF!

书中的代码语法过时了,改写为以下(测试通过):

        <Button>
            
<Button.LayoutTransform>
                
<ScaleTransform  ScaleX="3" ScaleY="3" />
            
</Button.LayoutTransform>
            
<StackPanel Orientation="Horizontal">
                
<Canvas Width="20" Height="18" VerticalAlignment="Center">
                    
<Ellipse Canvas.Left="1" Canvas.Top="1" Width="16" Height="16"
                      Fill
="Yellow" Stroke="Black" />
                    
<Ellipse Canvas.Left="4.5" Canvas.Top="5" Width="2.5" Height="3"
                      Fill
="Black" />
                    
<Ellipse Canvas.Left="11" Canvas.Top="5" Width="2.5" Height="3"
                      Fill
="Black" />
                    
<Path Data="M 5,10 A 3,3 0 0 0 13,10" Stroke="Blue" />
                
</Canvas>
                
<TextBlock VerticalAlignment="Center">Click!</TextBlock>
            
</StackPanel>
        
</Button>

ScaleTransform将button放大3倍。
Canvas上画图,画一个笑脸,3个椭圆,黄色是脸的轮廓,黄色是眼睛。蓝色钢笔画的是嘴巴——可以顺便了解这四个元素在Canvas上是怎么精确定位的。
posted @ 2007-03-31 11:28  包建强  Views(2001)  Comments(2Edit  收藏  举报