2013-05-06 54 views
1

我需要從Windows手機在我的應用程序目錄中的圖片,所以我加一個孩子的Windows當我點擊文本在這個孩子的Windows我添加了一個按鈕,我叫照片選擇器任務的Windows Phone 7.1

公共部分類AnnotationControl:ChildWindow {

public ObservableCollection<string> cercle { get; set; } 
    public AnnotationControl() 
    { 
     InitializeComponent(); 


    } 



    private void ChildWindow_Closing_1(object sender, System.ComponentModel.CancelEventArgs e) 
    { 

    } 

    private void btnsave_Click_1(object sender, RoutedEventArgs e) 
    { 
        this.DialogResult = true; 
    } 



    private void btnCancel_Click_1(object sender, RoutedEventArgs e) 
    { 
     this.DialogResult = true; 
    } 



    private void browse_Click(object sender, RoutedEventArgs e) 
    { 
PhotoChooserTask objPhotoChooser = new PhotoChooserTask(); 
       objPhotoChooser.Completed += new EventHandler<PhotoResult>(PhotoChooseCall); 
       objPhotoChooser.Show(); 
    } 

,但是當我點擊了按鈕,選擇照片的應用程序崩潰 「Application_UnhandledException」 有人有任何想法,請

+0

嘗試使用breakpiont追查確切exception.and也提到在哪一行代碼是崩潰調試 – Mohit 2013-05-06 12:28:27

回答

0

使用,這可能是有幫助的

private void changeImage(object sender, RoutedEventArgs e) 
    { 

     PhotoChooserTask photoChooserTask = new PhotoChooserTask(); 
     photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed); 
     photoChooserTask.Show(); 
    } 
void photoChooserTask_Completed(object sender, PhotoResult e) 
    { 
     if (e.TaskResult == TaskResult.OK) 
     { 

      System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(); 
      bmp.SetSource(e.ChosenPhoto); 

      imageTapped.Source = bmp; 

     } 
    }