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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:41:23+00:00 2026-05-25T18:41:23+00:00

I use the textName for the user to enter his name. Then typing, the

  • 0

I use the textName for the user to enter his name. Then typing, the textchanged event updates the listbox with the names that matchs with the input, then the user can click on an item (CompletedName in listbox), and when it happens I need the textbox updates with the item content.. This problem started to happen when I changed the “GivenName” (as a field from the table I query) for the “CompletedName”.. (it is a string concat from the query as u see above)

I have this LINQ query:

var players =
                    from p in context.Player
                    where (p.GivenName.StartsWith(TextName.Text.Trim()) || p.Number.StartsWith(TextName.Text) || p.Surname.StartsWith(TextName.Text) )
                    select new { CompleteName = p.GivenName + " " + p.Surname + " (" + p.Number + ")"};

Then I make this the source for a listbox named listNames and I have this textbox:

<TextBox Name="TextName" Text="{Binding ElementName=listNames, Path=SelectedItem.CompleteName}"/>

When I run it, the next error is shown:
“A Two Way or OneWayToSource binding cannot work on the read-only property ‘CompleteName’ of type ‘<>f__AnonymousType0`1[System.String]'”

I understand, of course that it can not be a TwoWay or OneWayToSource. But I need the user can add content to the textName, because it is also a search textbox, without updating the SelectedItem on the listbox.

If I add to the textbox the expression Mode=OneWay.. nothing happens in the textName control, I mean it doesnt show the item from the listbox..
What should I do for make it work??

  • 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-25T18:41:24+00:00Added an answer on May 25, 2026 at 6:41 pm

    I will reply my own answer for next people with the same problem. As I couldn’t make it work with the Mode=OneWay i did this:

    public class CompleteNamesResuls
        {
            public String CompleteName { get; set; }
        }
      private void TextName_TextChanged(object sender, TextChangedEventArgs e)
        {
                    var players =
                        from p in context.Player
                        where (p.GivenName.StartsWith(TextName.Text.Trim()) || p.Number.StartsWith(TextName.Text) || p.Surname.StartsWith(TextName.Text))
                        select new CompleteNamesResuls(){ CompleteName = p.GivenName + " " + p.Surname + " (" + p.Number + ")" };
    
        }
    

    That way, instead of using the Anonimous Type that was the OnlyRead source of

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

Sidebar

Related Questions

I usually use like this $ find -name testname.c ./dir1/dir2/testname.c $ vi ./dir1/dir2/testname.c it's
Use case: A does something on his box and gots stuck. He asks B
Use case: user clicks the link on a webpage - boom! load of files
Use Case When a user goes to my website, they will be confronted with
In my web app I have a dynamically generated form that I use to
I'm trying to use Nokogiri to grab some data from an XML file, then
I wrote a simple webform that will take the user's information (via POST) and
I want to Use only the HTML Controls on my page. For that i
Which one to use <label>Name</label> <asp:Label Text=Name runat=server></asp:Label> Genreally we are using label to
I need to allow a user to redirect from a page that collects user

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.