wpf MVVMLight的DataGrid绑定数据

数据绑定需要跟上下文绑定,并且将relativesource的ancestortype值设置为子窗口

<Button Content="弹窗" CommandParameter="{Binding}" Command="{Binding DataContext.DParaCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />

原文地址:https://www.cnblogs.com/ganzhihui/p/10476449.html