title: How can I solve this XAML Binding error?
body: <p>First some background, which can be condensed into editing a property VatCode of VatCodeViewModel.</p>
  
  <p>I have a StockItem with two particular properties in the ViewModel:</p>
  
  <pre><code>public class StockItemViewModel : ViewModelBase
  {
      private VatCodeViewModel _vatCode;
  
      public VatCodeViewModel VatCode
      {
          get { return _vatCode; }
          set
          {
              if (_vatCode != value)
              {
                  _vatCode = value;
                  RaisePropertyChanged("VatCode");
              }
          }
      }
  }
  </code></pre>
  
  <p>The VatCode property accepts a VatCodeViewModel type.</p>
  
  <p>To manage the editing experience, I have a ViewModel called EditStockItemViewModel. This has meta-data such as IsDirty, IsNew, etc., but has the Item property set to the item being edited - in this case an instance of StockItemViewModel. The Item property is in the base class (of TViewModel == StockItemViewModel) ...</p>
  
  <pre><code>public class UnMappedEditableViewModelBase&lt;TViewModel&gt; : ViewModelBase
  {
      private TViewModel _item;
  
      public TViewModel Item
      {
          get { return _item; }
          set
          {
              if (_item != value)
              {
                  _item = value;
                  RaisePropertyChanged("Item");
              }
          }
      }
  }
  </code></pre>
  
  <p>and the implementation class (EditStockItemViewModel, which has Item of StockItemViewModel) ...</p>
  
  <pre><code>public class EditStockItemViewModel : UnMappedEditableViewModelBase&lt;StockItemViewModel&gt;
  {
          private ObservableCollection&lt;VatCodeViewModel&gt; _vatCodes=new ObservableCollection&lt;VatCodeViewModel&gt;();
  
      public ObservableCollection&lt;VatCodeViewModel&gt; VatCodes
      {
          get { return _vatCodes; }
          set
          {
              if (_vatCodes != value)
              {
                  _vatCodes = value;
                  RaisePropertyChanged("VatCodes");
              }
          }
      }
  
  
  public EditStockItemViewModel()
          :base()
  {
          if (IsInDesignMode)
          {
          }
          else
          {
                                  RefreshVatCodesList(null); // refreshes VatCodes property
  
  
              Save = new RelayCommand(() =&gt;
                  {
                                                  // save functionality snipped
  
                  }, () =&gt;
              {
                  bool canExecute =                        Item.VatCode!=null; // this is ALWAYS null - binding failing
                  return canExecute;
              });         
          }
      }
  
  
  }
  </code></pre>
  
  <p><em>Therefore the ViewModel.Item property is always the item being edited.</em></p>
  
  <p>A fragment of my view ...</p>
  
  <pre><code>    &lt;TextBlock Text="VAT Code:" Grid.Column="1" Grid.Row="3" Style="{StaticResource ComboHeaderTextBlock}" /&gt;
      &lt;telerik:RadComboBox Grid.Column="2" Grid.Row="3" Style="{StaticResource RadComboBox}" Width="300" HorizontalAlignment="Left"
                  ItemsSource="{Binding VatCodes}" SelectedValuePath="Item.VatCode" 
                  ClearSelectionButtonVisibility="Collapsed"
                  CanAutocompleteSelectItems="True"
                  CanKeyboardNavigationSelectItems="True"
                  IsEditable="False"
                  OpenDropDownOnFocus="False"
                  IsFilteringEnabled="False"
                  EmptyText="Select ..."&gt;
          &lt;telerik:RadComboBox.SelectedValue&gt;
              &lt;Binding Path="Item.VatCode" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type UserControl}}" &gt;
                  &lt;Binding.ValidationRules&gt;
                      &lt;DataErrorValidationRule /&gt;
                  &lt;/Binding.ValidationRules&gt;
              &lt;/Binding&gt;
          &lt;/telerik:RadComboBox.SelectedValue&gt;
          &lt;telerik:RadComboBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;TextBlock Text="{Binding Key}" Style="{StaticResource TextBlock}" /&gt;
                      &lt;TextBlock Text="{Binding Name}" Style="{StaticResource DimTextBlock}" /&gt;
                      &lt;TextBlock Text="{Binding ActiveRate.Rate}" Margin="5 5 0 5" /&gt;
                      &lt;TextBlock Text="%" Margin="0 5 5 5"  /&gt;
                  &lt;/StackPanel&gt;
  
              &lt;/DataTemplate&gt;
          &lt;/telerik:RadComboBox.ItemTemplate&gt;
      &lt;/telerik:RadComboBox&gt;
  </code></pre>
  
  <p>So at the end of all this, I have:</p>
  
  <p>VatCode that binds to [ViewModel].Item.VatCode and uses [ViewModel].VatCodes as source.</p>
  
  <p>The list is populated and appears fine. I know that the ViewModel is binding correctly.</p>
  
  <p>The problem is the VatCode is NOT binding to the Item.VatCode property. So when I get to the Save method, the Item.VatCode property is null (ie. not working).</p>
  
  <p>I am getting the following binding error which appears to be related:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 17 : Cannot get 'Item' value (type
    'String') from '' (type 'VatCodeViewModel').
    BindingExpression:Path=Item.VatCode; DataItem='VatCodeViewModel'
    (HashCode=27875274); target element is 'RadComboBox' (Name=''); target
    property is 'NoTarget' (type 'Object')
    TargetParameterCountException:'System.Reflection.TargetParameterCountException:
    Parameter count mismatch.</p>
  </blockquote>
  
  <p>Clearly the error indicates my binding expression Item.VatCode is suspect, but I'm not sure how to correct it.</p>