Struggling to setup Bindings dynamically for my UserControl (WPF TextBox)
I have a custom textbox user control which I am trying to access the different properties from (for storing user input) I am struggling to set them up as each textbox needs to link to a different property...I made a dependancyproperty which then links them through UserInput, where I am attempting to bind each textbox to a different property, however when testing to see if the property is storing the values, its not. Attached is snippets of relevant code as well as an example of one of the properties (please let me know if u need anything more), any input would be appreciated...maybe theres a simpler approach?





8 Replies
Generally seems ok besides this. Needs to be the name of the property.

I tried changing that, however I dont think it is my issue. My textbox property (UserInputProperty) is the one giving me issues.
Here is what happens when I input something, as you can see its not reading whats in the textbox correctly

The user control has the textbox, which is bound to the dependancy property (UserInput)...the idea is to allow me to set where the text needs to be bound to when i use the usercontrol, so that i can set it for multiple properties, as shown in the second image below this


Probably needs a two-way binding in the registration here

new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
or something close.Im not sure if it changes anything, however this is the wrong dependancyproperty you are looking at.
I attempted changing it anyway and I also did the same thing for the UserInputProperty, it didnt change anything. I will mess around with the two ways and see if I can get it working. If you have any other ideas please let me know, I am really stuck on this.

Figured it out, my style had a property that was messing with it. Once I removed that, it fixed