title: OnPropertyChanged not updating UI for xzing barcode scanner for xamarin
body: <p>I'm using mvvm thoughout my app and data binding and property changes are working everywhere else in the application but for some reason, on my view using XZing Barcode Scanner, my view is not updating after I scan an item.</p>
  <p>I'm used to working with XAML ViewModel and Codebehind but they way I set up the barcode scanner is only ViewModel and Codebehind/alone class. So maybe I'm missing something simple that I am just not used to doing.</p>
  <p>I've posted some code below that is an example of just one of the properties not updating, the PartName for productsLable.Text. It is bound when the page first loads and the dummy PartName shows correctly but after scanning a new item, I update the ScannedPart in my ViewModel but the &quot;get&quot; is never called after I set and call OnPropertyChanged();</p>
  <p>This is working well in other parts of my application but maybe I am missing something silly here, like I said I am more comfortable working with bindings in XAML. Do you see anything I might be doing wrong or missing?</p>
  <p>Thanks in advance.</p>
  <pre><code>public class TimsCustomScanPage : ContentPage
      {
          ZXingScannerView zxing;
          TimsCustomOverlay overlay;
          RequestPartsViewModel viewModel;
  
          public TimsCustomScanPage(RequestPartsViewModel viewModel) : base()
          {
             //Attaching ViewModel
              this.viewModel = viewModel;
              this.BindingContext = viewModel;
              //Scanner found barcode
              zxing.OnScanResult += (result) =&gt;
              {
                  // Stop analysis until we navigate away so we don't keep reading barcodes
                  zxing.IsAnalyzing = false;
                  //Setting new scanned part
                  viewModel.ScannedPart = viewModel.Parts.FirstOrDefault();
              };
  --Some more code--
   
  var productsLabel = new Label()
              {
                  //Text = &quot;Find New Part&quot;,
                  TextColor = Color.Black,
                  WidthRequest = 150,
                  HorizontalOptions = LayoutOptions.Start,
                  VerticalTextAlignment = TextAlignment.Center,
                  Padding = new Thickness(0, 0, 0, 0),
              };
              //Binding text property 
              productsLabel.SetBinding(Label.TextProperty, &quot;PartName&quot;);
              productsLabel.BindingContext = viewModel.ScannedPart;
  }
  </code></pre>
  <p>ViewModel</p>
  <pre><code>public class RequestPartsViewModel : BaseViewModel
      {
          public ObservableCollection&lt;TimsCategory&gt; Categories { get; set; }
          public ObservableCollection&lt;TimsCategory&gt; FavoriteCategories { get; set; }
          public ObservableCollection&lt;TimsPart&gt; Parts { get; set; }
          public TimsCategory CurrentSelection { get; set; }
          public Command LoadItemsCommand { get; set; }
          TimsPart scannedPart;
          string partName;
          int totalRequestedParts;
  
          public RequestPartsViewModel()
          {
              Title = &quot;Request Parts&quot;;
              Categories = new ObservableCollection&lt;TimsCategory&gt;(db.Table&lt;TimsCategory&gt;().ToList());
              Parts = new ObservableCollection&lt;TimsPart&gt;(db.Table&lt;TimsPart&gt;().ToList());
              TotalRequestedParts = 0;
              ScannedPart = new TimsPart();
              ScannedPart.PartName = &quot;Scan New Part&quot;;
              ScannedPart.AvailableQuantity = 0;
  
              //Attach parts to categories 
              foreach (var item in Categories)
              {
                  int newId = item.CategoryId;
                  var partsForCategories = Parts.Where(p =&gt; p.CategoryId == newId);
                  var partsForCategoriesCollection = new ObservableCollection&lt;TimsPart&gt;(partsForCategories);
                  item.Parts = partsForCategoriesCollection;
              }
              
              FavoriteCategories = new ObservableCollection&lt;TimsCategory&gt;(Categories.Take(6).ToList());
  
              LoadItemsCommand = new Command(async () =&gt; await ExecuteLoadItemsCommand());
          }
  
          public TimsPart ScannedPart
          {
              get
              {
                  return scannedPart;
              }
              set
              {
                  if (scannedPart != value)
                  {
                      scannedPart = value;
                      OnPropertyChanged(&quot;PartName&quot;);
                      OnPropertyChanged(&quot;RequestedQuantity&quot;);
                      OnPropertyChanged(&quot;AvailableQuantity&quot;);
                      OnPropertyChanged(&quot;ScannedPart&quot;);
                  }
              }
          }
  </code></pre>
  <p>Base ViewModel</p>
  <pre><code>public class BaseViewModel : INotifyPropertyChanged
      {
          public SQLiteConnection db = TimsData.database;
  
          bool isBusy = false;
          public bool IsBusy
          {
              get { return isBusy; }
              set { SetProperty(ref isBusy, value); }
          }
  
          string title = string.Empty;
          public string Title
          {
              get { return title; }
              set { SetProperty(ref title, value); }
          }
  
          protected bool SetProperty&lt;T&gt;(ref T backingStore, T value,
              [CallerMemberName]string propertyName = &quot;&quot;,
              Action onChanged = null)
          {
              if (EqualityComparer&lt;T&gt;.Default.Equals(backingStore, value))
                  return false;
  
              backingStore = value;
              onChanged?.Invoke();
              OnPropertyChanged(propertyName);
              return true;
          }
  
          #region INotifyPropertyChanged
          public event PropertyChangedEventHandler PropertyChanged;
          protected void OnPropertyChanged([CallerMemberName] string propertyName = &quot;&quot;)
          {
              var changed = PropertyChanged;
              if (changed == null)
                  return;
  
              changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
          #endregion
      }
  </code></pre>