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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:51:10+00:00 2026-06-14T23:51:10+00:00

I am developing project using MVVM pattern.In the project I have two viewmodel namely

  • 0

I am developing project using MVVM pattern.In the project I have two viewmodel namely

  1. CountryViewModel and 2. EmpViewModel

In countryviewmodel I have stored information about country,state,city etc.

In EmpViewModel I have a control which have combo box which displays country name and selected value is set to country id which are in CountryViewModel.

Here is code:

<ComboBox Grid.Row="0" Grid.Column="1" Margin="3"
             ItemsSource="{Binding CountryViewModel.Countries}" SelectedValue="{Binding Title}"
             SelectedItem="{Binding CountryViewModel.SelectedCountry,Mode=TwoWay}"                               
             SelectedValuePath="Country_Id" DisplayMemberPath="Title">
    </ComboBox>

This is working fine.

I have local property country id in EmpViewModel and want to bind it to SelectedValue property of Combobox which I can get if I remove CountryViewModel from CountryViewModel.SelectedCountry.

But problem is I have another combobox for state which is dependent on Country combo box.
Edit: i.e in Country ViewModel I have called method GetAllState() when SelectedCountry changes.

So can I bind SelectedValue property of Combobox to both CountryViewModel.SelectedCountry from CountryViewModel and Country_Id from EmpViewModel?

  • 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-14T23:51:11+00:00Added an answer on June 14, 2026 at 11:51 pm

    I found a workaround

    I have write following method in an interface:

     public interface IViewModel
    {
        T GetValue<T>(string propertyName);
    }
    

    In country view model I implement this method as:

     public override T GetValue<T>(string propertyName)
        {
            T result = default(T);
            result = (T)Convert.ChangeType(this.SelectedCountry, typeof(T), null); }
    

    And in Emp View Model I added following line:

    newEmp.Country_Id = this.CountryViewModel.GetValue<Country>("SelectedCountry").Country_Id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application using WPF/MVVM. I have a WCF data service project
I'm developing a project using the MVVM pattern in WPF. One of the key
I am using C# and developing a winform application. I have a project class
I am developing a website using MVC 3, I have a web setup project
For you all information i am developing one java project using Eclipse to interact
I have recently joined a new developing project building a thick client application using
im now developing a project using winpcap..as i have known packets being sniffed are
I'm developing one web application project using java for education industry.In this Admin have
I'm developing a project using PostGIS to hold spatial data where I have records
I'm developing a project using a layered architecture. I have a DAL in which

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.