how do i bind a property declared in a viewmodel to take value from another viewModel?
let me explain
i have 2 ViewModels (Implements INotifyPropertyChanged) and 1 View
InvoiceView ( just my invoice design no matter if is a user control or window or a dataTemplate)
InvoiceViewModel
NoteListingVM (this viewmodel has a property let's name it TableRefID)
In the ViewInvoice i have an expander with it's dataContext set to (NoteListingVM) to show some notes that are linked with the specific invoiceID
I have a problem when i try the following
<Expander Header="NOTES" DockPanel.Dock="Top" Foreground="{StaticResource AlternateForeGround}">
<DockPanel>
<DockPanel.DataContext>
<WendBooks:NoteListingVM TableRefID="{Binding InvoiceID}" x:Name="TransactionNotes"></WendBooks:NoteListingVM>
</DockPanel.DataContext>
A 'Binding' cannot be set on the 'TableRefID' property of type 'NoteListingVM'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
so as the error said, i cannot use a property.
Then i think to use a DependencyProperty. But DependencyProperty cannot work properly in ViewModels if you implement an InotifyPropertyChanged. ( and this is what most users suggest when you implement a ViewModel - "INotifyPropertychanged")
DependencyPropertys are work well when you have a userControl or CustomControl. But this is not my case(i dont have a usercontrol or customControl i only have a ViewModel that i want to assign / pass "parameter" to the NoteListingViewModel when the InvoiceID changed)
so how i will send the InvoiceID (only xaml) to the NoteListingViewModel to filter and show only notes that are link to the current invoice i have front on me? what is the proper way? i am sure something i missed or misunderstand the mvvm pattern?