silverlight for win phone常用控件

(1)TextBlock,支持Run和LineBlack来格式化文本

        Run是用来显示文本内容,LineBlack作用是换行,例子代码如下

 

这是一个 WP7 演示程序 来自 helloxyz

 

(2)Image控件

网络文件Source="http://cn.bing.com/fd/hpk2/CentralParkWinter_ZH-CN850374802.jpg"

本地文件Source="/Image/bing.jpg"(注意要把图片属性的build action改为content)

 

(3)UI布局控件

   Canvas控件,绝对定位

 

            <Canvas>
                <Button Canvas.Left="100" Canvas.Top="100" Content="按钮1" Name="button1"/>
                <Button Canvas.Left="211" Canvas.Top="502" Content="按钮2" Name="button2"/>
                <Button Canvas.Left="121" Canvas.Top="224" Content="按钮3" Name="button3"/>
            </Canvas>  

 

    在ScrollViewer显示屏幕完整内容,通过手指拉动可以看到全部内容

 

            <ScrollViewer>
            <Canvas>
                <Button Canvas.Left="100" Canvas.Top="100" Content="按钮1" Name="button1"/>
                <Button Canvas.Left="211" Canvas.Top="502" Content="按钮2" Name="button2"/>
                <Button Canvas.Left="121" Canvas.Top="224" Content="按钮3" Name="button3"/>
            </Canvas>
            </ScrollViewer>

 

 

StackPanel控件自动定位

 

            <StackPanel Name="ButtonStackPanel">
                <Button Height="72" Width="140" Content="OK1" Name="button1" />
                <Button Height="72" Width="140" Content="OK2" Name="button2" />
                <Button Height="72" Width="140" Content="OK3" Name="button3" />
                <Button Height="72" Width="140" Content="OK4" Name="button4" />
                <Button Height="72" Width="140" Content="OK5" Name="button5" />
            </StackPanel>

            

 

 

事件重写

    if (e.Orientation == PageOrientation.LandscapeLeft || e.Orientation == PageOrientation.LandscapeRight)
            {
                ButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
            }
            else if (e.Orientation == PageOrientation.PortraitDown || e.Orientation == PageOrientation.PortraitUp)
            {
                ButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Vertical
            }

 

posted @ 2010-12-14 15:20  helloxyz  Views(429)  Comments(2Edit  收藏  举报