zoukankan      html  css  js  c++  java
  • Windows Phone 8弹窗

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

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
    
    <Grid Height="280" x:Name="gridBox" VerticalAlignment="Top" Background="Black">
    <Grid.Projection>
    <PlaneProjection/>
    </Grid.Projection>
    <Grid.RowDefinitions>
    <RowDefinition Height="100"/>
    <RowDefinition Height="100"/>
    <RowDefinition Height="70"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <TextBlock Text="图像选择" FontSize="30" Margin="10,50,10,10"/>
    <ContentControl HorizontalAlignment="Left" FontSize="30" Margin="40,0,0,0" Content="请选择载入图像的方式" Grid.Row="1" Grid.ColumnSpan="2"/>
    <Button Grid.Row="2" Grid.Column="0" Name="btnCamera" Content="相机" Width="200" Click="btnCamera_Click"/>
    <Button Grid.Row="2" Grid.Column="1" Name="btnAlbum" Content="相册" Width="200" 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;
    主页调用
  • 相关阅读:
    出于安全考虑,office outlook禁止对潜在不安全因素的附件访问,如何解决
    70级圣骑士OK了,纪念下先!
    03.配置putty连接Linux系统,并实现中英文输入输出;配置vnc服务器
    想了解你好有的装备及属性吗,副本及飞行点的位置吗?简单!
    Windows Server 2008 下载、安装、激活
    同事的U盘写保护了!
    重新开始核心编程,Windows的开始
    如何知道某PC接入到交换机的哪个端口上
    DK装备获取线路总结
    Windows Server 2008 评估时间延期
  • 原文地址:https://www.cnblogs.com/ZXdeveloper/p/3580956.html
Copyright © 2011-2022 走看看