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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:17:05+00:00 2026-05-26T04:17:05+00:00

I have a ComboBox with a custom ItemsTemplateSelector. The Items for the control are

  • 0

I have a ComboBox with a custom ItemsTemplateSelector. The Items for the control are defined in xaml, like so:

<ComboBox ItemTemplateSelector="{StaticResource CommonListSelectorTemplates}" >
    <local:MyItem Heading="First" Text="First Item"/>
    <local:MyItem Heading="Second" Text="Second Item"/>
    <local:MyItemWithValue Heading="Third" Text="Third Item" Value="{Binding TheValue}" />
</ComboBox>

The third item has a Value property that I wish to bind to the TheValue property on the ComboBox’s DataContext. This binding fails with the following error:

“Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=TheValue; DataItem=null; target element is ‘MyItemWithValue’ (HashCode=49465727); target property is ‘Value’ (type ‘Int32’)”

I guess it’s becuase the Items collection does not use the ComboBox’s DataContext. I have tried different permutations of RelativeSource without success, so my question is: What is the best way to accomplish the binding?

EDIT:

RV1987 answered my question as it was stated. However, what I want is for the binding to be two-way, and neither of the solutions proposed seem to work for this. The trouble may be that I can’t get the binding in the proxy to be two-way; the compiler refuses to accept

DataContext=”{Binding, Mode=TwoWay}”

  • 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-26T04:17:05+00:00Added an answer on May 26, 2026 at 4:17 am

    ComboboxItems are not part of visual tree so they are not connected to the data context of the Combobox. You have to use the proxy binding to refer to the dataContext. For detailed and clean approach please have a look at this link –

    http://tomlev2.wordpress.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/

    Also, look at this (same issue but in this case its datagrid in place of combobox) as suggested by AngelWPF, this was also something new to me –

    Bind datagrid column visibility MVVM

    Edit- Moreover, you need to set binding mode Two way in your comboboxitem instead of setting it in StaticResource. This should work –

    <local:MyItemWithValue Heading="Third" Text="Third Item" Value="{Binding TheValue, Mode=TwoWay}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ComboBox in a custom control. How can I expose specific events
I have created a custom comboBox that supports images in front of the items
I have a DataGrid (WPF Toolkit) with a custom combobox like edit template of
I have a custom combobox ( MyComboBox ) defined in my code (by making
I have a wpf combobox with some custom items. When the dropdown button is
I have a style to a custom control that inherits from combobox that I
I have a ComboBox that I set up like this: this.cmbCustomerJob.DisplayMember = display; this.cmbCustomerJob.AutoCompleteMode
I have a combobox from which i need to programmatically disable items depending on
I have created a custom combobox that has a LABEL property so when we
I have a ComboBox that is bound to an ObservableCollection of custom UserControls. Each

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.