winforms - Converting UI from Windows Forms to WPF databinding -
i have application user interface in windows forms. code behind user interface communicates service.
for example, have next code:
public partial class mainwindow : window { private keylessaccesslogic servicelogic; public mainwindow() { initializecomponent(); servicelogic = new keylessaccesslogic(); //loadvalues(); } public keylessaccesslogic myservicelogic { { homecoming servicelogic; } set { servicelogic = value; // raisepropertychanged("myservicelogic"); } } private void binddatasource() { cmb_user_name.datasource = null; cmb_user_name.sorted = false; cmb_user_name.datasource = servicelogic.users; cmb_user_name.displaymember = "name"; }
and xaml:
<combobox height="23" horizontalalignment="left" margin="6,71,0,0" name="cmb_user_update" verticalalignment="top" width="120" itemssource="{binding path=myservicelogic.users}" displaymemberpath="name" />
now recreated ui in wpf, , i'm bit lost on new format. believe illustration gave here 1 of examples of difference between wpf , windows forms.
how can allow application know datasource should of dropdown-box cmb_user_name
? servicelogic
central block of service, accessing illustration database.
as sec thing, have listbox show me devices. tried approach datasource differently show else have tried:
<listbox height="100" horizontalalignment="left" margin="6,44,0,0" name="listbox_detected" verticalalignment="top" width="120" itemssource="{binding path=servicelogic.thedeviceslist}" displaymemberpath="name" />
use xaml
that:
<combobox itemssource="{binding myservicelogic.users}" selecteditem="{binding user}" displaymemberpath="name" />
create property servicelogic
in viewmodel
hold servicelogic
object:
private servicelogic myservicelogic; public servicelogic myservicelogic { { homecoming myservicelogic; } set { myservicelogic = value; raisepropertychanged("myservicelogic"); } }
i assume users
observablecollection
. or can create property holds users
collection directly.
wpf winforms visual-studio-2010 user-interface
No comments:
Post a Comment