i have window @ startup select interface , port 2 comboboxs. when click done, takes main window, can see 2 more comboxes identical. these have selected values picked in popup window. can in code behind?
here's popup window, winresetinterface.xaml:
window x:class="simpliphy.winresetinterface" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="winresetinterface" height="280" width="259"> <grid margin="0,-1,2,1"> <combobox name="cmbinterface" itemssource="{binding interface}" displaymemberpath="name" horizontalalignment="left" margin="94,52,0,0" verticalalignment="top" width="91"/> <button x:name="btnfinishsetup" click="btnfinishsetup_click" content="done" horizontalalignment="left" margin="76,173,0,0" verticalalignment="top" width="75"/> <combobox x:name="cmbport" itemssource="{binding selecteditem.port, elementname=cmbinterface}" horizontalalignment="left" margin="94,88,0,0" verticalalignment="top" width="91"/> </grid> and in code behind:
namespace project { public partial class winresetinterface : window { public observablecollection<model.device_class> interface { get; set; } public winresetinterface() { initializecomponent(); datacontext = this; interface = new observablecollection<model.device_class>(); interface.add(new device_class() { name = "xgbe", port = new observablecollection<string>() { "0" } }); interface.add(new device_class() { name = "sata0", port = new observablecollection<string>() { "0", "1", "2", "3" } }); } } private void btnfinishsetup_click(object sender, routedeventargs e) { mainwindow main = new mainwindow(); app.current.mainwindow = main; this.close(); main.show(); //set selected options on device stats sidebar ///this i'm stuck! main.cmbinterface_main.selecteditem = cmbinterface.selecteditem; } } in mainwindow, have combobox filled same way box1, cmbinterface. can not set 2 selecteditems equal each other?
you this:
main.cmbinterface_main.selectedindex = cmbinterface_main.findstringexact(cmbinterface.text, 0); although loopedcode's comment better answer.
Comments
Post a Comment