XAML 属性设置Windows Phone笔记

本文介绍了Windows Phone 7 (WP7) 开发中的一些实用技巧,包括如何设置图片和按钮样式、显示弹出提示框、配置启动页面及快捷方式名称等。此外,还展示了如何使用匿名方法简化代码,并解释了应用程序栏的配置方法。

图片地址:

<Image Name="imgBomb" Stretch="Fill"  Width="100" Height="100"  Source="/CrazyBomb;component/Images/SleepState.png" MouseLeftButtonDown="imgBomb_MouseLeftButtonDown" />

 

按钮背景:

<Button Name="btnOverGame" Click="btnOverGame_Click" Width="100" Height="100" Visibility="Collapsed">
                <Button.Background>
                    <ImageBrush ImageSource="/CrazyBomb;component/Images/OverIcon.jpg" />
                </Button.Background>
</Button>

 

WP弹出提示框是一样的。

string scoreMessage = string.Format("Your Score : {0} !", GetScore());
            MessageBox.Show(scoreMessage, "GameOver", MessageBoxButton.OK);

 

也可以使用匿名方法

btnSettingItem.Click += delegate(object o, RoutedEventArgs e)
                    { MessageBox.Show("SettingItem is Clicked!", "Click", MessageBoxButton.OK); };

 

修改启动页面

WMAppManifest.xml 文件的

<Tasks>
      <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
    </Tasks>

 

快捷方式标题名字

image

WMAppManifest.xml 文件的

  <App xmlns="" ProductID="{689bb09d-e38a-4ce7-bbf8-7e4080ee0db8}" Title="wp7SaveImage背景设置"

 

页面导航

NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

 

应用程序栏

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" Text="OK"/>
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.cancel.rest.png" Text="Cancel"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

 

属性值加×

纯数字代表固定高度(像素),数字加×代表按比例分配,即在固定值分配完成了后,按比例分配,如:10×、100、20×、30× ,会先分配固定值100,然后按10:20:30的比例分配高度或者是宽度。

 

匿名方法现在可以省略到如下程度了。

if (null==_timer)
           {
               _timer = new DispatcherTimer();
           }
           _timer.Interval = TimeSpan.FromSeconds(2);
           _timer.Tick += (sender, e) =>
               {
                   Index++;
                   if (Index==AdvWords.Length)
                   {
                       Index = 0;
                   }
                   _mangoIndicator.Text = AdvWords[Index];
               };
           _timer.Start();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值