c# - WPF-Frame navigate to same page only works once -
in page, can add together items. press "save" add together one. heres code:
private void btn_save_click(object sender, routedeventargs e) { // adding item db , list maindata.maindataitem mdi_temp = new maindata.maindataitem(); mdi_temp.int_af = convert.toint32(tb_af.text); mdi_temp.int_ho = convert.toint32(tb_ho.text); mdi_temp.int_st = convert.toint32(tb_st.text); mdi_temp.int_std = convert.toint32(tb_std.text); mdi_temp.int_dia = convert.toint32(tb_dia.text); mdi_temp.int_eck = convert.toint32(tb_eck.text); mdi_temp.int_mid = ((helperclasses.main_vm)this.datacontext).mdo_tmpstore.int_id; mdi_temp.str_bauteil = str_bauteil; mdi_temp.str_defekt = str_defekt; mdi_temp.str_massnahme = str_massnahme; mdi_temp.str_feld = tb_feld.text; mdi_temp.str_zeile = tb_zeile.text; mdi_temp.int_pos = convert.toint32(tb_pos.text); helperclasses.sql_class.dbadditem(mdi_temp); // navigate helperclass.navigate("pages/new_item.xaml"); } and void in helperclass:
public static void navigate(string str_uri) { ((mainwindow)application.current.windows[0]).fm_maincontainer.source = new uri(str_uri, urikind.relative); } the first time click on btn_save page reloads, sec time onyl add together item
another alternative create overload of navigate in helper class
public static void navigate(object target) { ((mainwindow)application.current.windows[0]).fm_maincontainer.content = target; } ans utilize way
// navigate new_item item = new new_item(); helperclass.navigate(item); this ensure have new initialization every time
c# wpf xaml frame reload
No comments:
Post a Comment