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
-
I've create a simply project to demonstrate my issue. Basically, I have a custom
UserControl
that exposes aDependencyProperty
, which is bound to theWindow
view model (anObservableObject
). I'm looking for a way for aUserControl
to make modifications to another view model via anICommand
parameter, 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 theAddItemUserControl
needing to have a direct reference to the collection. Instead, the collection is passed as a parameter to someAddItemCommand
on the user control. The Collection is then bound as aDependencyProperty
on 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
TextBox
in the control. The same issue exists - theDepedencyProperty
is 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