Windows Phone 8 中的弹出窗口 [英] Popup in windows phone 8
本文介绍了Windows Phone 8 中的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示一个带有媒体元素的弹出窗口作为一个控件.当用户单击按钮时,我必须显示此弹出窗口.当用户点击设备的后退按钮时,弹出窗口应该关闭.
I want to show a popup with media element as one control. When user clicks on the button, then I have to show this popup. And when user clicks on the back button of the device then the popup should be closed.
请帮助我如何在 Windows Phone 8 应用程序中执行此操作.
Please help me how to do this in windows phone 8 application.
推荐答案
Popup with MediaElement(视图是PhoneApplicationPage
的名称)
<Popup
x:Name="popup">
<Grid
Background="{StaticResource PhoneChromeBrush}"
Height="{Binding Path=ActualHeight, ElementName=view}"
Width="{Binding Path=ActualWidth, ElementName=view}">
<MediaElement />
</Grid>
</Popup>
应用栏
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBarIconButton
Click="ShowPopup"
IconUri="/Icons/show.png"
Text="show" />
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
背后的代码
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (this.popup.IsOpen)
{
this.popup.IsOpen = false;
e.Cancel = true;
}
base.OnBackKeyPress(e);
}
private void ShowPopup(object sender, EventArgs e)
{
this.popup.IsOpen = true;
}
这篇关于Windows Phone 8 中的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文