I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface. I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource. I continue to get a Command "Not Found" error. Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be great.
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
The
DataContext
of items in aListBox
will be the item they represent. So if yourItemsSource
is bound to a list of Widgets, then theDataContext
of yourListBoxItem
will be a Widget.If you need to access the
DataContext
of theListBox
, rather than theListBoxItem
, then you can useRelativeSource
: