Goo*_*ofy 1 c# wpf fullscreen windows-phone windows-phone-8
我正在开发Windows Phone 8 app并在XAML中拥有这样的Image视图:
<Image Name="Image"
Grid.Row="0"
Visibility="Collapsed"
Width="Auto"
Height="Auto"
Tap="Image_tap"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="1,1,1,1"/>
Run Code Online (Sandbox Code Playgroud)
现在我有这个事件叫Tap="Image_tap",当我点击图像我想要全屏显示相同的图像,顶部和底部没有任何栏,如何实现这一点?
另一种方法是在不在页面之间传递图像细节的情况下显示弹出窗口:
private void HandleTapImage(object sender, GestureEventArgs e)
{
var myPopup = new Popup
{
Child = new Image
{
Source = ((Image) sender).Source,
Stretch = Stretch.UniformToFill,
Height = Application.Current.Host.Content.ActualHeight,
Width = Application.Current.Host.Content.ActualWidth
}
};
myPopup.IsOpen = true;
}
Run Code Online (Sandbox Code Playgroud)
(选择最适合您需求的Strech值).但是,使用此方法,您必须在方法中手动隐藏ApplicationBar和SystemTray(如果存在)HandleTapImage.您还必须注意隐藏Popup并再次显示条形图.
底栏是ApplicationBar顶吧SystemTray.如果您创建的新页面不包含ApplicationBar和,SystemTray.IsVisible则为false,则您有一个全屏页面.现在,不要只在一个Grid根,只放一个Image,你可以使用该页面作为全屏查看器.
<phone:PhoneApplicationPage
x:Class="SimpleApp.FullScreenPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="False">
<Image Name="myImage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Stretch="Uniform"/>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)
在主页中,您点击图像:
private void myImg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
string context = ((sender as Image).Source as BitmapImage).UriSource.ToString();
NavigationService.Navigate(new Uri(String.Concat("/Page1.xaml?context=", context), UriKind.RelativeOrAbsolute));
}
Run Code Online (Sandbox Code Playgroud)
在全屏页面中:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string context = this.NavigationContext.QueryString["context"];
myImage.Source = new BitmapImage(new Uri(context, UriKind.RelativeOrAbsolute));
base.OnNavigatedTo(e);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7448 次 |
| 最近记录: |