日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Windows Phone 7 程序菜单栏ApplicationBar

發布時間:2025/3/20 windows 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Windows Phone 7 程序菜单栏ApplicationBar 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ApplicationBar控件時windows phone 7上的一個菜單,它傳統的Windows程序的菜單的作用類似。
ApplicationBar(ApplicationBarIconButton和ApplicationBarMenuItem)相關的類定義在Microsoft.Phone.Shell命名空間。與UIElement和FrameworkElement等常規Silverlight編程的類層次是完全分開的,嚴格說來ApplicationBar不是你的頁面的可視化的一部分。
一個ApplicationBar最多可包含四個按鈕。如果還有額外的選項可以通過菜單項來添加,這些菜單項默認是不顯示的。只有在點擊菜單欄右側的省略號(或省略號下方的區域)時才會顯示出來。

該項目包含一個MediaElement MoviePlayer播放影片,而ApplicationBar包含第一,播放,暫停,最后四個選項。

<!--LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MOVIE PLAYER" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement Name="mediaElement"
Source
="http://localhost/123.wmv"
AutoPlay
="False"
MediaOpened
="OnMediaElementMediaOpened"
MediaFailed
="OnMediaElementMediaFailed"
CurrentStateChanged
="OnMediaElementCurrentStateChanged" />

<TextBlock Name="statusText"
HorizontalAlignment
="Left"
VerticalAlignment
="Bottom" />

<TextBlock Name="errorText"
HorizontalAlignment
="Right"
VerticalAlignment
="Bottom"
TextWrapping
="Wrap" />
</Grid>
</Grid>

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBarIconButton
x:Name="appbarRewindButton"
IconUri
="Images/appbar.transport.rew.rest.png"
Text
="rewind"
IsEnabled
="False"
Click
="OnAppbarRewindClick" />

<shell:ApplicationBarIconButton
x:Name="appbarPlayButton"
IconUri
="Images/appbar.transport.play.rest.png"
Text
="play"
IsEnabled
="False"
Click
="OnAppbarPlayClick" />

<shell:ApplicationBarIconButton
x:Name="appbarPauseButton"
IconUri
="Images/appbar.transport.pause.rest.png"
Text
="pause"
IsEnabled
="False"
Click
="OnAppbarPauseClick" />

<shell:ApplicationBarIconButton
x:Name="appbarEndButton"
IconUri
="Images/appbar.transport.ff.rest.png"
Text
="to end"
IsEnabled
="False"
Click
="OnAppbarEndClick" />
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar> View Code using System;
using System.Windows;
using System.Windows.Media;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace MoviePlayer
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();

// Re-assign names already in the XAML file
appbarRewindButton = this.ApplicationBar.Buttons[0] as ApplicationBarIconButton;
appbarPlayButton
= this.ApplicationBar.Buttons[1] as ApplicationBarIconButton;
appbarPauseButton
= this.ApplicationBar.Buttons[2] as ApplicationBarIconButton;
appbarEndButton
= this.ApplicationBar.Buttons[3] as ApplicationBarIconButton;
}

// ApplicationBar buttons
void OnAppbarRewindClick(object sender, EventArgs args)
{
mediaElement.Position
= TimeSpan.Zero;
}

void OnAppbarPlayClick(object sender, EventArgs args)
{
mediaElement.Play();
}

void OnAppbarPauseClick(object sender, EventArgs args)
{
mediaElement.Pause();
}

void OnAppbarEndClick(object sender, EventArgs args)
{
mediaElement.Position
= mediaElement.NaturalDuration.TimeSpan;
}

// MediaElement events
void OnMediaElementMediaFailed(object sender, ExceptionRoutedEventArgs args)
{
errorText.Text
= args.ErrorException.Message;
}

void OnMediaElementMediaOpened(object sender, RoutedEventArgs args)
{
appbarRewindButton.IsEnabled
= true;
appbarEndButton.IsEnabled
= true;
}

void OnMediaElementCurrentStateChanged(object sender, RoutedEventArgs args)
{
statusText.Text
= mediaElement.CurrentState.ToString();

if (mediaElement.CurrentState == MediaElementState.Stopped ||
mediaElement.CurrentState
== MediaElementState.Paused)
{
appbarPlayButton.IsEnabled
= true;
appbarPauseButton.IsEnabled
= false;
}
else if (mediaElement.CurrentState == MediaElementState.Playing)
{
appbarPlayButton.IsEnabled
= false;
appbarPauseButton.IsEnabled
= true;
}
}
}
}

總結

以上是生活随笔為你收集整理的Windows Phone 7 程序菜单栏ApplicationBar的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。