数据绑定需要跟上下文绑定,并且将relativesource的ancestortype值设置为子窗口
<Button Content="弹窗" CommandParameter="{Binding}" Command="{Binding DataContext.DParaCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
数据绑定需要跟上下文绑定,并且将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