c# - How do I control the clicks of a browse button? -
i have browse button, , 2 empty images (image1, image2). want first click browse button , load image (image1). on sec click want load image (image2).
i'm new wpf , c# in general. guess need method command clicks of button? have thought this? highly appreciate it.
this code behind attempt:
private void button1_click(object sender, routedeventargs e) { openfiledialog fd = new openfiledialog(); fd.defaultext = ".tif"; fd.filter = "(*.tif,*.tiff)|*.tif;*.tiff"; fd.showdialog(); string fname = fd.filename; textbox1.text = fname; image1.source = new bitmapimage(new uri(fd.filename)); } after this, first image displayed in image1, when browse image comes on top of image 1, , not in image2. how can create sec image browse display in image2? maybe like, if button clicked 1 time, image should load image2? or if image1 total load image2? i'm not sure!
oh , purpose of create interface lets user browse different images shown in listbox, , when user clicks each image, displays in window , user can zoom in , out , on.
but right i'm stuck little part of project!
while question why want such thing, utilize following. also, please show effort next time. relatively easy solution!
private bool _imageoneset; public mainwindow() { initializecomponent(); _imageoneset = false; } private void button_click(object sender, routedeventargs e) { if (!_imageoneset) { // set image 1 _imageoneset = true; } else { // set image 2 } } i utilize private field set false. first time button_click event gets triggered, _imageoneset still false, can set first image.
the sec (and third, 4th etc...), _imageoneset true set sec image.
c# wpf
No comments:
Post a Comment