Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application where the user selects different tables to edit. I'd like to reuse a TextBox for each different table. Is there a way to change the DisplayMemberPath at run time?
Posted
Comments
VR Karthikeyan 7-Oct-15 13:39pm    
What is the way to choose tables that you have provided in your application? Are you using ComboBox or any other control to list out table name?
Robert Kamarowski 7-Oct-15 14:01pm    
Yes, I'm using a ComboBox.
Richard Deeming 7-Oct-15 14:12pm    
The WPF TextBox control doesn't have a property called DisplayMemberPath.
Robert Kamarowski 7-Oct-15 14:33pm    
ugh... thank you. Sorry about the confusion.

I need to set the text value:

Text = "{Binding path=VendorName, mode=TwoWay}"
Richard Deeming 7-Oct-15 14:38pm    
You can get to the binding with the BindingOperations.GetBinding method[^], which would let you change the path from code.

However, it's almost certainly going to be easier to use MVVM to display the data, in which case you can just use a single property in the view-model, with code to decide which property from the model it uses.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900