2014-04-06 29 views
-1

我應該在這個構造函數中寫什麼來顯示從前一個列表中選擇的圖像。如何使構造函數顯示選定的圖像?

public SelectionDisplay(object label, Brush background) 
    { 
     //Do stuff 
    } 

例如,如果我選擇的考拉(見PIC1)從圖像列表中,一個新的窗口應該與考拉的寬圖像和簡短說明打開。我試圖儘可能清楚;我還發布了生成圖像的代碼。

private void KinectTileButtonClick(object sender, RoutedEventArgs e) 
    { 

     var button = (KinectTileButton)e.Source; 
     var image = button.CommandParameter as BitmapImage; 
     var selectionDisplay = new SelectionDisplay(button.Label,button.Background); // aici poti apoi sa mai trimiti si imaginea ca parametru pentru constructor 
     this.kinectRegionGrid.Children.Add(selectionDisplay); 
     e.Handled = true; 

    } 
  var files = Directory.GetFiles(@".\GalleryImages"); 
  foreach (var file in files) 
      { 
       FileInfo fileInfo = new FileInfo(file); 

       BitmapImage bi = new BitmapImage(); 
       bi.BeginInit(); 
       bi.UriSource = new Uri(file, UriKind.Relative); 
       bi.EndInit(); 

       var button = new KinectTileButton 
       { 
        Label = System.IO.Path.GetFileNameWithoutExtension(file), 
        Background = new ImageBrush(bi), 
        Tag = file 
       }; 
       var selectionDisplay = new SelectionDisplay(button.Label as string, button.Tag as string); 
       this.wrapPanel.Children.Add(button); 

http://i57.tinypic.com/2liegrk.png

回答

0

能否請你修改你的要求嗎? 我得到的是你有一些圖像的列表,可能是一些描述,只要你點擊其中一個圖像,它會在新的屏幕上打開。你想通過視圖模型的構造函數來執行這個功能。請確認這是否正確的理解。

+0

我有一張可以在前一張圖片中看到的圖片列表。當用戶點擊圖像時,應打開一個新窗口,其中應顯示所選圖像及其各自的描述。 – user3493747

+0

所以如果我的假設是正確的,你在Dictionary對象中有這個圖像和描述? –

相關問題