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

  • Home
  • SEARCH
  • 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 3213558
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:57:30+00:00 2026-05-17T14:57:30+00:00

I try to implement PrepareContainerForItemOverride method of ItemsControl. It will put items to TextBox.

  • 0

I try to implement PrepareContainerForItemOverride method of ItemsControl. It will put items to TextBox. It works nice, but how can I binding an item to the textbox text property? One way mode works nice, but when I want two way mode, I have to know the path.

Here is my code:

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            if (element is TextBox)
            {
                //((TextBox)element).Text = (string)item;
                Binding binding = new Binding("I don't know what should i write here.");
                binding.Mode = BindingMode.TwoWay;
                ((TextBox)element).SetBinding(TextBox.TextProperty, binding);
            }
}

Thank you for your help!

  • 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-17T14:57:31+00:00Added an answer on May 17, 2026 at 2:57 pm

    If the commented line in the code in your question is what you have before then it indicates that the type of item you are providing is String. Two way binding on a string makes no sense the binding would not know where to assign the new value.

    The type of items being displayed would need to be some object that has a property of type String, it would be the name of this proprerty that you pass to the Binding constructor.

    That said its not clear why you would even need to sub-class ItemsControl in this way. Why not:-

    <ItemsControl ItemSource="{Binding SomeEnumberableOfObjectsThatHaveASomeStringProperty}">
      <ItemsControl.ItemTemplate>
        <DataTemplate>
           <TextBox Test="{Binding SomeString, Mode=TwoWay}" />
        </DataTemplate>
      </ItemsControl.ItemTemplate>
    </ItemsControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to implement simple server on python based on HTTPServer. How can i
I try to implement the abstract DbCommand class (like OdbcCommand, OleDbCommand, ...) but a
I try to implement a table function by following Tony Andrews example . But
I try to implement memory mapped technics in my OpenCL program, but it's doesn't
I try to implement new validationrules in my MVC-Project but i wont become a
I try to implement simple touch event handling on Blackberry 9550 emulator, but it
When I try to implement the below code: $('.touchelement').bind({'touchstart':function(e){ console.info(e.touches.item(0)); }}); It shows the
I try to add an addons system to my Windows.Net application using Reflection; but
I try Request.Form.Set(k, v) but it's throwing exception Collection is read-only
I try to implement point lights in OpenGL with GLSL. I send all 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.