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 7657575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:04:05+00:00 2026-05-31T13:04:05+00:00

In my project I am binding an observable collection to a datagrid. Every column

  • 0

In my project I am binding an observable collection to a datagrid. Every column The datagrid has a combo box which is bound property and that returns a list of string. The selecteditem of the combo box is bound to another property of my observable collection. The get accessor works fine in combo box but the set does not work. I need that to work coz I have to save the changes to my data base.

Here is some part of my XAML

<DataGrid  SelectedItem="{Binding SelectedPartProperty, Mode=TwoWay}"
              ItemsSource="{Binding AllPartProperties}" AutoGenerateColumns="False" Grid.Row="1" Margin="416,6,302,0">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Name" Binding="{Binding PropertyName,Mode=TwoWay}" IsReadOnly="false"/>
            <DataGridTemplateColumn Header="Data Type" IsReadOnly="false">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox SelectedItem="{Binding PropertyDataType, Mode=TwoWay}"
                           ItemsSource="{Binding DataType}" 
                           Background="White" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

        </DataGrid.Columns>
    </DataGrid>

My main view model

public ObservableCollection<PartPropertyViewModel> AllPartProperties
    {
        get
        {
            if (SelectedPartNumber == null)
            {
                _allProperties = new ObservableCollection<PartPropertyViewModel>();
                return _allProperties;
            }
            PartPropertyViewModel tempPartPropertyViewModel;
            ObservableCollection<PartPropertyViewModel> newPartPropertyViewModel = new ObservableCollection<PartPropertyViewModel>();
            foreach (PartProperty p in SelectedPartNumber.PartNumberEntity.PartProperties)
            {
                tempPartPropertyViewModel = new PartPropertyViewModel(p);
                newPartPropertyViewModel.Add(tempPartPropertyViewModel);
            }

            _allProperties = newPartPropertyViewModel;
            return _allProperties;
        }
        set
        {
            _allProperties = value;              

        }

    }

Another viewModel

class PartPropertyViewModel : ViewModelBase
{
    private PartProperty _partPropertyEntity;      
    private string _propertyDataType;
    private string[] _dataType;
    private PartParameterViewModel _partParameters;

    public PartPropertyViewModel(PartProperty partProperty)
    {
        PartPropertyEntity = partProperty;
        _partParameters = new PartParameterViewModel(partProperty);
    }

    //public PartPropertyViewModel()
    //{
    //    //PartPropertyEntity = new PartProperty();           
    //}


    public PartProperty PartPropertyEntity
    {
        get 
        {
            return _partPropertyEntity;
        }
        set 
        {
            _partPropertyEntity = value;
        }
    }
    public string PropertyName
    {
        get
        {
            if (PartPropertyEntity == null ||  PartPropertyEntity.ConfigurationProperty == null)
                return "";
            else
                return PartPropertyEntity.ConfigurationProperty.chrCPProperty;
        }
        set
        {
            PartPropertyEntity.ConfigurationProperty.chrCPProperty = value;
            OnPropertyChanged("PropertyName");
        }
    }

    public string[] DataType
    {
        get 
        {
            _dataType = new string[] { "Number", "String"};                
            return _dataType;
        }
        set
        {
            _dataType = value;
            OnPropertyChanged("DataType");
            OnPropertyChanged("PropertyDataType");
        }

    }
    public string PropertyDataType
    {
        get
        {
            if (PartPropertyEntity == null || PartPropertyEntity.ConfigurationProperty == null)
                return "";

            if (PartPropertyEntity.ConfigurationProperty.bitCPIsNumeric)
                _propertyDataType = DataType[0];
            else
                _propertyDataType = DataType[1];
            return _propertyDataType;
        }
        set
        {
            _propertyDataType = value;

            if (String.Compare(value,"Number") == 0)
                PartPropertyEntity.ConfigurationProperty.bitCPIsNumeric = true;
            else
                PartPropertyEntity.ConfigurationProperty.bitCPIsNumeric = false;

            OnPropertyChanged("PropertyDataType");
        }
    }



    public PartParameterViewModel PartParameters
    {
        get
        {
           return  _partParameters;
        }
    }

}//end of class
  • 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-05-31T13:04:06+00:00Added an answer on May 31, 2026 at 1:04 pm

    You are binding to a string array

      public string[] DataType 
    

    String does not have a property PropertyDataType and I doubt the get is called either.

    Need to bind to a collection like List or ObservableCollection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a observable collection of type Project, that I want to be displayed
In my latest project, I have a ListView that is bound to an ObservableCollection
I'm binding a GridView to a collection of objects that look like this: public
I use MVVM for my project, the binding that set to DataTable work correctly
I am creating a WPF app with a list box that I am binding
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I'm starting a project which I think would benefit from bindings (I've got a
How would I generate automatic bindings for a C project that is built using
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
Every project invariably needs some type of reporting functionality. From a foreach loop in

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.