Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change image display when ComboBox select change
#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;


Messages In This Thread
RE: Change image display when ComboBox select change - by marktech - 03-01-2023, 04:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)