c# - How can I apply MVVM and Commands in this specific WPF situation? -


I have trouble with the MVVM pattern and command in my WPF app. The problem is not so much that the MVVM pattern, but more than the stuff that is running on my GUI. I will explain the situation:

My app can be in some files I have a class with the function DoStuff (int limit) My user user interface has the following items: < / P>

  • button DoStuffBtn to start parsing.
  • A text box LimitTxt to fill a limit.
  • Enable or disable a checkbox .

When you uncheck " LimitChk , then LimitTxt.Text =" " and LimitTxt.IsEnabled = false . You will repeat "check" LimitChk , then LimitTxt.IsEnabled = false , but the text remains empty until you fill something .

I have read several tutorials on the command in WPF and MVVM but I do not think that my case would be inserted in that mold. The example I have given is actually a small part of my UI Is but I can not do this very well.

I am going through such questions as:

  • Do I have to command for LimitChk (enabled and disabled) or just a toggle?
  • If I type int to LimitTxt , if I drop it What happens if I do it and disable it?
  • Is it just a clean way to use DoStuff (Int32.Parse (LimitTxt.Text) > pressed ?
  • If I use two commands on LimitChk , then what happens with CanExecute () the function of ICommand Determines whether LimitChk is enabled?

The main question is: How will the situation happen? I have seen some links on WPF, Command and MVVM:


  • What do I still think that I can get as much pi from the UI There are also things like the UI affecting the UI, i.e. Unchecking LimitChk disables LimitText . Even so, I think that I should keep a distinction between information related to UI and actions and things that really need to be done with actual work.

    gt; text box text =" {binding limit} "isEnabled =" {binding limitations} "/> gt; button content =" Pars "command =" {Binding Pars Command} "/>

    You would like to start ParseCommand like this:

      this.ParseCommand = New DelegateCommand & lt; object & gt; (parseFile);   

    Now, let's also fill that LimitTextIsEnabled property:

      public bool LimitTextIsEnabled {// Clear comparison because checkboxes Get IISChecked is nullable. Return it. Limit IsChecked == True; } Private set {}}   

    Your parseFile method will then pass the value of the actual parsing logic to the value of LimitValue .

    I declared that LimitValue declares the property as a string to avoid the code with a clear converter, or other verification code, to avoid clutter. You can choose to accept">

    Of course, I have not implemented it completely, but I want to underline a pattern where you are not using the command to update the status of other widgets. Instead, tie these properties to properties that are managed in your Viomodalal.


    Comments

    Popular posts from this blog

    oracle - The fastest way to check if some records in a database table? -

    php - multilevel menu with multilevel array -

    jQuery UI: Datepicker month format -