Binding a DependencyPropery to an IRelayCommand<T> #241
thomasrea0113
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've create a simply project to demonstrate my issue. Basically, I have a custom
UserControlthat exposes aDependencyProperty, which is bound to theWindowview model (anObservableObject). I'm looking for a way for aUserControlto make modifications to another view model via anICommandparameter, so as to not have to directly couple the control to the window.My actual use case is a separate
AddItemUserControl, which will add an item to anObservableCollection, without theAddItemUserControlneeding to have a direct reference to the collection. Instead, the collection is passed as a parameter to someAddItemCommandon the user control. The Collection is then bound as aDependencyPropertyon the user control, where the binding points back to theWindow's view model collection.The simple project I've created to demonstrate my issue, simply binds a string from the window to the command parameter, and then uses it to update a
TextBoxin the control. The same issue exists - theDepedencyPropertyis not being bound to the value that I am settinghttps://github.com/thomasrea0113/wpf-DependencyProperty-bind
I realize this may be a code-smell, and am open to alternative solutions. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions