I am trying to do something that one would think should be very simple (at least it is in WPF). I have a page with a listbox and a datatemplate, now that datatemplate calls
There is a concept called x:Bind in Windows 10 UWP. In x:Bind the code behind becomes the datacontext for the binding. So if you add a property in the user control's code behind, pointing to the view model, that can be used to bind the command.
public class MyButton
{
public ViewModel ButtonViewModel
{
get
{
return ButtonViewModelObject;
}
}
}
In XAML -
Refer - https://msdn.microsoft.com/en-us/library/windows/apps/mt204783.aspx
OR
You can use ElementName with traditional binding to achieve the result.
Refer - Can't access datacontext of parent
Update: To access delete command from the page's datacontext, the following method can be used, assuming - the change of usercontrol's datacontext (from customer) to the page's datacontext doesn't affect anything else present inside the usercontrol.