wpf mvvm模式,在添加控件自身事件(LostFocus)的时候:
1.首先nuget管理工具中下载 behaviors 或者 interactivity
2.Command绑定不能直接绑定,要使用RelativeSource来绑定。例如:
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=StackPanel},Path=DataContext.LostFocusCommand}" AncestorType要绑定根,也就是上层控件才有效果