c# - How to work in MVVM -


hi using wpf , devexpress! new c# world , have no experience in mvvm. have watched different videos learn mvvm. related basics of mvvm (why efficient, etc) wrote code in wpf. there 3 buttons in code : add new data, edit data , refresh grid. each button has it's click event defining it's functionality. want convert simple basic wpf code mvvm framework. can guide me it's conversion mvvm. edition

     void editrow(int focrowhand, entities a)         {          name nametext = grid.getrow(focrowhand) name;          try             {             if (nametext.name1 != string.empty)                 {                  update_id = nametext.id;                 txtname2.text = update_text = nametext.name;                  if (panel3.visibility == system.windows.visibility.visible)                     {                     panel1.visibility = system.windows.visibility.visible;                     panel3.visibility = system.windows.visibility.collapsed;                     }                  else                     {                     panel1.visibility = system.windows.visibility.collapsed;                     panel3.visibility = system.windows.visibility.visible;                     }                 }             }         catch (exception err)             {             dxmessagebox.show(err.stacktrace);              }          }          private void button1_copy_click(object sender, routedeventargs e)             {              if (view.focusedrowhandle == 0)                 {                 dxmessagebox.show("please select item grid list");                 }             else                 {                 try                     {                     int focrowhand = view.focusedrowhandle;                     entities = new entities();                      if (grid.isgrouprowhandle(focrowhand))                         {                         int childcount = grid.getchildrowcount(focrowhand);                         (int = 0; < childcount; i++)                             {                             int childhandle = grid.getchildrowhandle(focrowhand, i);                             editrow(childhandle, a);                             }                         }                     else                         {                         editrow(focrowhand, a);                         }                      }                 catch (exception ee)                     {                     dxmessagebox.show(ee.stacktrace);                     }                 }              } 

insertion

    private void insertion()   {   if (txtname.text != string.empty)       {       if (dxmessagebox.show("are sure, want insert?", "insert item-confirmation", messageboxbutton.yesno, messageboximage.question) == messageboxresult.yes)           {           try               {                    entities dbcontext = new entities();                   name name = new name();                   name.my_name = txtname.text;                   dbcontext.names.add(name);                   dbcontext.savechanges();                   txtname.text = null;                   refresh();                   }            catch (exception err)               {               dxmessagebox.show(err.stacktrace);                }           }       else           txtname.text = null;       }    } 

if question not clear or want more information please ask me. thank :)

i think no 1 spend time writing code you. have learn youself learning tutorials. perhaps can follow tutorials give insight developing mvvm based application (not focusing on efficiency)

follow thread:

mvvm: tutorial start finish?

it contains need.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -