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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:45:39+00:00 2026-05-17T21:45:39+00:00

I have a simple user control which wraps some logic around an AutoCompleteBox. This

  • 0

I have a simple user control which wraps some logic around an AutoCompleteBox. This question could apply to any ItemsControl control like a dropdown or listbox though.

<UserControl>
    <Grid Background="White">
        <sdk:AutoCompleteBox Name="myACB" ItemsSource="{Binding myData}" />
    </Grid>
</UserControl>

I want expose the SelectedItem property of the AutoCompleteBox in a parent where the control is used. My user control is using a view model as its data context though. Otherwise, I think I could just bind the SelectedItem to a dependency property of the user control.

I need to be able to have the parent detect when the child autocompletebox selected item changes. How can I go about this?

  • 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-17T21:45:40+00:00Added an answer on May 17, 2026 at 9:45 pm

    Just create a dependency property in the UserControl and bind it with your internal control like the following:

    1) Add a dependency property in the CustomControl:

    public System.Collections.IEnumerable ItemsSource
        {
            get { return (System.Collections.IEnumerable)GetValue(ItemsSourceProperty); }
            set { SetValue(ItemsSourceProperty, value); }
        }
    
        // Using a DependencyProperty as the backing store for ItemsSource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ItemsSourceProperty =
            DependencyProperty.Register("ItemsSource", typeof(System.Collections.IEnumerable), typeof(UserControl1), new UIPropertyMetadata(null));
    

    2) Bind the internal control with the dependency property:

    <UserControl ... x:Name="control"     ... >
    
    <ListBox ItemsSource="{Binding ElementName=control, Path=ItemsSource}" />  
    

    Edit: Implement the ItemsSource

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

Sidebar

Related Questions

I have a simple user control, which is essentially just an AutoCompleteBox with some
I have a simple user control that contains some buttons that fire events which
I have a simple user control with this code: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs"
I have a user control which does some validation in the ValidateChildren method which
I have simple SL user control. A listbox which shows all customers and on
I have a user control which shows list of latest announcements. This user control
I have a simple form on a view page, implemented as a user control,
I've created a simple user control which is manually created with something like MyUserControl
I have two questions. First one is simple: Is there any way to control
I have a simple application with just a window and a user control. The

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.