Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:37:59+00:00 2026-06-04T04:37:59+00:00

First some background, which can be condensed into editing a property VatCode of VatCodeViewModel.

  • 0

First some background, which can be condensed into editing a property VatCode of VatCodeViewModel.

I have a StockItem with two particular properties in the ViewModel:

public class StockItemViewModel : ViewModelBase
{
    private VatCodeViewModel _vatCode;

    public VatCodeViewModel VatCode
    {
        get { return _vatCode; }
        set
        {
            if (_vatCode != value)
            {
                _vatCode = value;
                RaisePropertyChanged("VatCode");
            }
        }
    }
}

The VatCode property accepts a VatCodeViewModel type.

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) …

public class UnMappedEditableViewModelBase<TViewModel> : ViewModelBase
{
    private TViewModel _item;

    public TViewModel Item
    {
        get { return _item; }
        set
        {
            if (_item != value)
            {
                _item = value;
                RaisePropertyChanged("Item");
            }
        }
    }
}

and the implementation class (EditStockItemViewModel, which has Item of StockItemViewModel) …

public class EditStockItemViewModel : UnMappedEditableViewModelBase<StockItemViewModel>
{
        private ObservableCollection<VatCodeViewModel> _vatCodes=new ObservableCollection<VatCodeViewModel>();

    public ObservableCollection<VatCodeViewModel> 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(() =>
                {
                                                // save functionality snipped

                }, () =>
            {
                bool canExecute =                        Item.VatCode!=null; // this is ALWAYS null - binding failing
                return canExecute;
            });         
        }
    }


}

Therefore the ViewModel.Item property is always the item being edited.

A fragment of my view …

    <TextBlock Text="VAT Code:" Grid.Column="1" Grid.Row="3" Style="{StaticResource ComboHeaderTextBlock}" />
    <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 ...">
        <telerik:RadComboBox.SelectedValue>
            <Binding Path="Item.VatCode" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type UserControl}}" >
                <Binding.ValidationRules>
                    <DataErrorValidationRule />
                </Binding.ValidationRules>
            </Binding>
        </telerik:RadComboBox.SelectedValue>
        <telerik:RadComboBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Key}" Style="{StaticResource TextBlock}" />
                    <TextBlock Text="{Binding Name}" Style="{StaticResource DimTextBlock}" />
                    <TextBlock Text="{Binding ActiveRate.Rate}" Margin="5 5 0 5" />
                    <TextBlock Text="%" Margin="0 5 5 5"  />
                </StackPanel>

            </DataTemplate>
        </telerik:RadComboBox.ItemTemplate>
    </telerik:RadComboBox>

So at the end of all this, I have:

VatCode that binds to [ViewModel].Item.VatCode and uses [ViewModel].VatCodes as source.

The list is populated and appears fine. I know that the ViewModel is binding correctly.

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).

I am getting the following binding error which appears to be related:

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.

Clearly the error indicates my binding expression Item.VatCode is suspect, but I’m not sure how to correct it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:38:00+00:00Added an answer on June 4, 2026 at 4:38 am

    Found it, I was misled by the example provided in the documentation. I should not have used the path SelectedValuePath. So my new code is:

     <TextBlock Text="VAT Code:" Grid.Column="1" Grid.Row="3" Style="{StaticResource ComboHeaderTextBlock}" />
            <telerik:RadComboBox Grid.Column="2" Grid.Row="3" Style="{StaticResource RadComboBox}" Width="300" HorizontalAlignment="Left"
                        ItemsSource="{Binding VatCodes}"  
                        ClearSelectionButtonVisibility="Collapsed"
                        CanAutocompleteSelectItems="True"
                        CanKeyboardNavigationSelectItems="True"
                        IsEditable="False"
                        OpenDropDownOnFocus="False"
                        IsFilteringEnabled="False"
                        EmptyText="Select ...">
                <telerik:RadComboBox.SelectedValue>
                    <Binding Path="Item.VatCode" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
                        <Binding.ValidationRules>
                            <DataErrorValidationRule />
                        </Binding.ValidationRules>
                    </Binding>
                </telerik:RadComboBox.SelectedValue>
                <telerik:RadComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Key}" Style="{StaticResource TextBlock}" />
                            <TextBlock Text="{Binding Name}" Style="{StaticResource DimTextBlock}" />
                            <TextBlock Text="{Binding ActiveRate.Rate}" Margin="5 5 0 5" />
                            <TextBlock Text="%" Margin="0 5 5 5"  />
                        </StackPanel>
    
                    </DataTemplate>
                </telerik:RadComboBox.ItemTemplate>
            </telerik:RadComboBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let me start with some background: I have a web service which accepts
I have two CSS rules following each other: .some td:first-child:before { content:url('path/to/image.png') ; }
First some background. I have a batch-type java process run from a DOS batch
First some brief background: I have an existing ASP.NET MVC 1 application using Entity
Some background first. I have a .net client agent installed on each of the
First some background information: We have three environments for our EJB3 application: test, development
Okay, first some background, I can't use any javascript library except YUI for this
First some background. I have a file, for simplicity's sake, let's call it test.txt.
First some background on the application. I have an application processing many independent tasks
First some background: I'm working on an application and I'm trying to follow MVVM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.