MVVM ICommand.CanExecute parameter is null

CommandParameter="{Binding}"

改为

CommandParameter="{Binding DataContext,RelativeSource={RelativeSource Self}}"
                            <StackPanel Orientation="Horizontal" >
                                <Button Content="×" CommandParameter="{Binding DataContext,RelativeSource={RelativeSource Self}}" Command="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.CmdConvertToFalse}"></Button>
                                <Button Content="√" CommandParameter="{Binding DataContext,RelativeSource={RelativeSource Self}}" Command="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.CmdConvertToTrue}"></Button>
                            </StackPanel>
原文地址:https://www.cnblogs.com/rock_chen/p/10239513.html