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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:57:40+00:00 2026-06-08T13:57:40+00:00

I have an UserControl(AutoComplete) with his own ViewModel. When I use the UserControl inside

  • 0

I have an UserControl(AutoComplete) with his own ViewModel. When I use the UserControl inside a window, it run well, connect to a service, and paint data correctly.
The UserControl datacontext is set via xaml, and is binded to a property of the main window viewModel.

Ok, now I want that the UserControl can load data from the main window view model. The thing is that, supposing the usercontrol loads countries. When I type in the Usercontrol it returns the list of countries and when I select one of them, i.e. “Spain”, the SelectedItem property of the Usercontrols updates to “Spain”. I want an object in main window viewModel to udate to “Spain” and vice-versa, if I update the country object in the main window viewmodel, the selecteditem of the user should update too.

How can I accomplish that

I have this in my mainview:

<amctrls:AmAutoCompleteView DataContext="{Binding controladorAutoCompleteCountry}" /> 

the user control loks like this:

<telerik:RadComboBox Margin="2,0,0,0" Grid.Row="0" Grid.Column="0"  
            IsEditable="True"
            Name="RadCbo"
            ItemsSource="{Binding objectList}" 
            DisplayMemberPath="{Binding fieldToShow}"
            OpenDropDownOnFocus="True"
            SelectedItem="{Binding selectedCountry, Mode=TwoWay}"
            Text="{Binding searchText, Mode=TwoWay}"
            IsTextSearchEnabled="False" 
            StaysOpenOnEdit="True" />

controladorAutoCompleteCountry is a property of my mainview wih is an instance of the usercontrol viewmodel.

The viewmodel of the main view manage addresses, and what I want is to bind an address country to the usercontrol in order to edit the address. If i have the usercontrol binded to an instance of its controller, how can I bind the Country object of the address?

  • 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-08T13:57:42+00:00Added an answer on June 8, 2026 at 1:57 pm

    If you need to make those 2 views independent which is good if you want to reuse your control, go with Event Aggregator or simple events. Whenever an item is selected in the user control, it will publish an event stating, something interesting has happened. Main viewmodel can subscribe to those events and do the required. A simple case would be a creating a static class with an event and RaiseEvent method, user control will RaiseEvent and main viewmodel with be subscribing the event. Data to be passed between them can be added to the event args.

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

Sidebar

Related Questions

I have a UserControl which contains a TextBox . When my main window loads
I have a usercontrol that I want to use as a ListBoxItem. <ListBox.ItemTemplate> <DataTemplate>
I have a usercontrol with a Tree inside it with, the command property binds
i have an usercontrol that has a public event. when i use this user
I have a usercontrol (UC) that is sometimes in a window and sometimes in
I have one UserControl nested inside the other UserControl, something like that: <uc:MyControl1> <uc:MyControl2
I'd better ask the question by example. Let's say I have UserControl and Window
I have a usercontrol in WPF that have 2 buttons inside. The buttons are
I have a usercontrol that I want to have the grid inside so I
I have a usercontrol inside a repeater, which has some custom validation. I create

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.