Windows Phone 8弹窗

新建一个UserControl,添加到相应位置

<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">

<Grid Height="" x:Name="gridBox" VerticalAlignment="Top" Background="Black">
<Grid.Projection>
<PlaneProjection/>
</Grid.Projection>
<Grid.RowDefinitions>
<RowDefinition Height=""/>
<RowDefinition Height=""/>
<RowDefinition Height=""/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="图像选择" FontSize="" Margin="10,50,10,10"/>
<ContentControl HorizontalAlignment="Left" FontSize="" Margin="40,0,0,0" Content="请选择载入图像的方式" Grid.Row="" Grid.ColumnSpan=""/>
<Button Grid.Row="" Grid.Column="" Name="btnCamera" Content="相机" Width="" Click="btnCamera_Click"/>
<Button Grid.Row="" Grid.Column="" Name="btnAlbum" Content="相册" Width="" Click="btnAlbum_Click"/>
</Grid>
</Grid>

前台代码

相应的后台代码

namespace ImageProcessing
{
public partial class MessagePhoto : UserControl
{
public MessagePhoto()
{
InitializeComponent();
//************让gridbox拉伸*********
this.gridBox.Width = Application.Current.Host.Content.ActualWidth;
}
//获取图像
void PictureCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
}
}
//打开相机
private void btnCamera_Click(object sender, RoutedEventArgs e)
{
CameraCaptureTask cameraCaptureTask = new CameraCaptureTask();
if (cameraCaptureTask != null)
{
cameraCaptureTask.Show();
}
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(PictureCaptureTask_Completed);
}
//打开相册
private void btnAlbum_Click(object sender, RoutedEventArgs e)
{
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
if (photoChooserTask != null)
{
photoChooserTask.Show();
}
photoChooserTask.Completed += new EventHandler<PhotoResult>(PictureCaptureTask_Completed);
}
}
}

后台代码

主页进行调用

Popup messagebox = new Popup();
messagebox.Child = new MessagePhoto();
messagebox.IsOpen = true;

主页调用

上一篇:在Android中,px,dp,dip,sp的不同之处


下一篇:ie浏览器 jsp中链接参数为中文的处理