Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change image display when ComboBox select change
#1
I create a dialog with a form and an image. Is there any way I can change the image displayed when the selected value in the combo box changes. Thanks
#2
you can use the event "SelectionChanged" from combobox.
 
Code:
Copy      Help
using System.Windows.Controls;
using System.Windows.Media.Imaging;



var b = new wpfBuilder("Window").WinSize(400, 400);
b.R.Add(out ComboBox cb).Items("Image 1|Image 2");
b.Row(-1).Add(out Image img);
b.End();


cb.SelectionChanged += (o, e) => {
    
    switch (cb.SelectedIndex) {
    case 0:
        img.Source = new BitmapImage(new Uri(@"wallpaper-1.jpg"));
        break;
    case 1:
        img.Source = new BitmapImage(new Uri(@"wallpaper-2.jpg"));
        break;
    }
    
};



if (!b.ShowDialog()) return;


Forum Jump:


Users browsing this thread: 1 Guest(s)