Prism to update Viewmodel from Model
<p>I think I ask my question incorrectly and have some bad code because of it.
What I want to do is have more of a Model-Controller(?)-ViewModel-View where I in the controller I can have code that is used in multiple ViewModels so I don't have to write it more than once.  The part I am having trouble getting a grasp on is how to update the ViewModel while in a loop in the Controller Class.  The controller has a loop counter that I want to use to update a parameter in the ViewModel but that is not being updated until I return to the ViewModel.</p>

<p>I am trying to figure out how to update a Viewmodel from a model using Prism.  I maybe going about it wrong but I thought I could make my class a bindablebase and then have it automatically update my viewmodel when it is modified versus using INotifyPropertyChanged.</p>

<p>I have a method that loops through some directories and keeps track of some files.  I would like to have the loop update a field that updates the viewmodel in real time since I am using BindableBase I believe that I should be able to use that to notify the ViewModel about the updates to the model.  Right now the code does not update the ViewModel automatically as I am a little lost as to how to accomplish this task.</p>

<p>Viewmodel</p>

<pre><code>public class P4LabelBatteryViewModel : BindableBase
    {
        private P4LabelBatteryModel p4LabelBatteryModel = new P4LabelBatteryModel();
        private ScriptsToTagModel scriptsToTagModel = new ScriptsToTagModel();
        private P4LabelBattery.Models.BatteryLocation batteryLocation = new BatteryLocation();


        public P4LabelBatteryViewModel()
        {
           P4LabelBattery.Models.BatteryLocation  p4LabelBattery = new BatteryLocation();

           // FilesProcessedBlck = p4LabelBattery.TestItem;


            this.GetBatteryBtn = new DelegateCommand(chooseFile, canChooseFile);
            this.NewLabelBtn = new DelegateCommand(chooseNewLabel, canNewLabel).ObservesProperty(() =&gt; NewLabel);
        }


        private string _batteryLocation = "Enter Location Here";
        public string BatteryLocation
        {
            get
            {
                return _batteryLocation;
            }
            set
            {
                SetProperty(ref _batteryLocation, value);
            }
        }

        public ICommand GetBatteryBtn
        {
            get;
            set;
        }


        private void chooseFile()
        {
            BatteriesToLoad = p4LabelBatteryModel.GetBatteryFileName();

            var b = BatteriesToLoad.Count;
            if (b != 0)
            {
                ScriptCollection = scriptsToTagModel.ReadInScrpts(BatteriesToLoad[b-1].BatteryLocationAdd);
                BatteryLocation = BatteriesToLoad[b - 1].BatteryLocationAdd;
            }
        }

        private bool canChooseFile()
        {
            if (BatteriesToLoad != null)
            {
                return true;
            }
            else
            {
                return true;
            }
        }


        public ICommand NewLabelBtn
        {
            get;
            set;
        }

        private void chooseNewLabel()
        {
            if (ScriptCollection.Count &gt; 0)
            {
                ScriptCollection = P4LabelBatteryModel.LocatePNGModel(NewLabel, ScriptCollection, batteryLocation);
//                FilesProcessedBlck = ScriptCollection.Count;
                ScriptCollection = P4LabelBatteryModel.TagsFilesModel(NewLabel, ScriptCollection, FilesProcessedBlck);
            }
        }

        private bool canNewLabel()
        {
            if (NewLabel == null || NewLabel == "Enter Label Here" || NewLabel == "")
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        private string _newLabel;
        public string NewLabel
        {
            get
            {
               return _newLabel;
            }
            set
            {
                SetProperty(ref _newLabel, value);
                canNewLabel();
            }
        }

        private int _filesProcessedBlck;
        public int FilesProcessedBlck
        {
            get
            {
                return _filesProcessedBlck;
            }
            set
            {
                SetProperty(ref _filesProcessedBlck, batteryLocation.TestItem);
            }

        }


        private ObservableCollection&lt;ScriptModel&gt; _scriptCollection = new ObservableCollection&lt;ScriptModel&gt;();
        public ObservableCollection&lt;ScriptModel&gt; ScriptCollection
        {
            get
            {
                return _scriptCollection;
            }
            set
            {
                SetProperty(ref _scriptCollection, value);
            }

        }

        private ObservableCollection&lt;BatteryLocation&gt; _batteriesToLoad = new ObservableCollection&lt;BatteryLocation&gt;();
        public ObservableCollection&lt;BatteryLocation&gt; BatteriesToLoad 
        {
            get
            {
                return _batteriesToLoad;
            }
            set
            {
                SetProperty(ref _batteriesToLoad, value);
            }

        }



    }
</code></pre>

<p>Model:</p>

<pre><code>class P4LabelBatteryModel : BindableBase
    {
        private string _MasterFile2 = "0";
        private ObservableCollection&lt;BatteryLocation&gt; batteryLocationColl = new ObservableCollection&lt;BatteryLocation&gt;();

        public ObservableCollection&lt;BatteryLocation&gt; GetBatteryFileName()
        {
            if (_MasterFile2 != "1")
            {
                Microsoft.Win32.OpenFileDialog _MasterFileDialog = new Microsoft.Win32.OpenFileDialog();

                _MasterFileDialog.DefaultExt = "*.*";
             //   _MasterFileDialog.Filter = "All Files (*.scr; *.SCR) | *.scr; *.SR";

                Nullable&lt;bool&gt; result = _MasterFileDialog.ShowDialog();

                BatteryLocation batteryLocation = new BatteryLocation();
                batteryLocation.BatteryLocationAdd =  _MasterFileDialog.FileName;

                if (result == true &amp;&amp; !batteryLocationColl.Contains(batteryLocation))
                {
                    batteryLocation.BatteryLocationAdd = _MasterFileDialog.FileName;
                    batteryLocationColl.Add(batteryLocation);
                }
            }
                return batteryLocationColl;
        }

        public static ObservableCollection&lt;ScriptModel&gt; LocatePNGModel(string NewLabel, ObservableCollection&lt;ScriptModel&gt; observableCollection, BatteryLocation FilesProcessedBlck)
        {
            string newLabel = NewLabel;
            var scriptsToTagColl = observableCollection;
            string[] files = null;
            FilesProcessedBlck.TestItem = 40;

            // ObservableCollection&lt;ScriptModel&gt; newCollection = new ObservableCollection&lt;ScriptModel&gt;();

            int CollCount = scriptsToTagColl.Count;
            for (int i = 0; i &lt; CollCount; i++)
            {

                //Check for 4th occurance of \ to search for .png files.
                // Modify path for non-standard script locations.
                if (!scriptsToTagColl[i].ScriptNameAdd.Contains("Scripts"))
                {
                    int j = 0;
                    int m = 0;

                    for (int k = 0; k &lt;= 4 &amp;&amp; k &lt; scriptsToTagColl[i].ScriptNameAdd.Count(); k++)
                    {
                        if (j != -1)
                        {
                            if ((j = scriptsToTagColl[i].ScriptNameAdd.IndexOf(@"\", j)) != -1 &amp;&amp; k == 4)
                            {
                                //add directory search for .png
                                string teststring = scriptsToTagColl[i].ScriptNameAdd;
                                int testint = teststring.Count();
                                int ttt = testint;
                                string _edtdString = teststring.Remove(j, testint - j);
                                try
                                {
                                    foreach (string d in Directory.GetDirectories(_edtdString))
                                    {
                                        try
                                        {

                                            files = Directory.GetFiles(d, "*.png", SearchOption.AllDirectories);

                                            foreach (string file1 in files)
                                            {
                                                ScriptModel _scriptModel = new ScriptModel();
                                                _scriptModel.ScriptNameAdd = file1;
                                                scriptsToTagColl.Add(_scriptModel);
                                              //  newCollection.Add(_scriptModel);
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                            //don't care right now.
                                            //files = null;
                                            //testscript2 = testscript.Insert(index + @"Scripts\".Length, @"Results\");
                                            //trimmed = testscript.TrimEnd('.', 's', 'c', 'r');
                                            //trimmed += @"\mill\Snapshots\BCM";
                                            int stophere = 2;


                                        }

                                    }
                                }
                                catch (Exception e)
                                {
                                    //don't care right now
                                    int stophere2 = 2;
                                }

                                break;
                            }
                            j++;
                        }
                    }
                }
                //End of check
                else
                {
                    string testscript = scriptsToTagColl[i].ScriptNameAdd;
                    int index = testscript.IndexOf(@"Scripts\");
                    files = null;
                    string testscript2 = testscript.Insert(index + @"Scripts\".Length, @"Results\");
                    string trimmed = testscript2.TrimEnd('.', 's', 'c', 'r');
                    trimmed += @"\mill\Snapshots\BCM";

                    if (Directory.Exists(@trimmed))
                    {
                        try
                        {

                            files = Directory.GetFiles(@trimmed, "*.*");

                            foreach (string file1 in files)
                            {
                                ScriptModel _scriptModel = new ScriptModel();
                                _scriptModel.ScriptNameAdd = file1;
                          //      newCollection.Add(_scriptModel);
                                scriptsToTagColl.Add(_scriptModel);
                            }
                        }
                        catch (Exception e)
                        {
                            //don't care right now.
                            files = null;
                            testscript2 = testscript.Insert(index + @"Scripts\".Length, @"Results\");
                            trimmed = testscript.TrimEnd('.', 's', 'c', 'r');
                            trimmed += @"\mill\Snapshots\BCM";


                        }
                    }
                }

            }

            return scriptsToTagColl;
        }

        public static ObservableCollection&lt;ScriptModel&gt; TagsFilesModel(string NewLabel, IList&lt;ScriptModel&gt; observableCollection, int FileCount)
        {
            string newLabel = NewLabel;
            var scriptsToTagColl = observableCollection;
            int fileCount = FileCount;

            var _p4LabelBatteryViewModel = new P4LabelBatteryViewModel();

            //This will generate an IPC when returned
            ObservableCollection&lt;ScriptModel&gt; newCollection = new ObservableCollection&lt;ScriptModel&gt;();

            int CollCount = scriptsToTagColl.Count;

            for (int i = 0; i &lt; scriptsToTagColl.Count; i++)
            {
                var stringToTest = scriptsToTagColl[i].ScriptNameAdd;
               string tempString = @" """;

              //  if (stringToTest.Contains(" "))
              //  {
                    tempString = tempString + stringToTest;
                    stringToTest = " " + tempString;
             //   }


                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                StringBuilder q = new StringBuilder();

                string FileName1 = @"c:\windows\system32\cmd.exe";
                string Arguments1 = string.Format("@ /c p4 tag -l {0} {1}", newLabel, stringToTest);

               proc.StartInfo = new ProcessStartInfo(FileName1, Arguments1);
               proc.StartInfo.RedirectStandardError = true;
               proc.StartInfo.UseShellExecute = false;
               proc.StartInfo.CreateNoWindow = true;
               proc.Start();

               q.Append(proc.StandardError.ReadToEnd());
                //while (!proc.HasExited)
                //{
                //    q.Append(proc.StandardOutput.ReadToEnd());

                //}
                string r = q.ToString();  

                if ( ! r.Contains("no such file(s)"))
                {
                scriptsToTagColl[i].BackGround = new SolidColorBrush(Colors.LightGreen);
                }

                newCollection.Add(scriptsToTagColl[i]);
            }

            return newCollection;
        }
    }

    public class BatteryLocation :BindableBase
    {
        private string _batteryLocationAdd;

        public string BatteryLocationAdd
        {
            get { return _batteryLocationAdd; }
            set { _batteryLocationAdd = value; }
        }

        private SolidColorBrush _backGround;
        public SolidColorBrush BackGround
        {
            get { return _backGround; }
            set { _backGround = value; }
        }

        private int _testItem = 100;
        public int TestItem
        {
            get {return _testItem;}
            set { _testItem = value; }

        }

    }

}
</code></pre>