Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以下方法或属性之间的调用不明确-WPF_C#_Wpf - Fatal编程技术网

C# 以下方法或属性之间的调用不明确-WPF

C# 以下方法或属性之间的调用不明确-WPF,c#,wpf,C#,Wpf,我有一个WPF表单,它有一些按钮来保存用户输入、删除和取消。我试图添加这样的功能:每当用户单击cancel按钮时,就会弹出一条消息。相反,它会在我的控制器中引发异常: "The call is ambiguous between the following methods or properties" 以下是我的看法: <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,0"&g

我有一个WPF表单,它有一些按钮来保存用户输入、删除和取消。我试图添加这样的功能:每当用户单击cancel按钮时,就会弹出一条消息。相反,它会在我的控制器中引发异常:

"The call is ambiguous between the following methods or properties"
以下是我的看法:

 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,0">                        
    <Button Name="DeleteButton" Command="{Binding DeleteCommand}" CommandParameter="{Binding Path=SelectedStory}"  Cursor="Hand" Height="25" IsEnabled="{Binding CanDelete}" Margin="5 0 0 0">Delete</Button>
    <Button Name="SubmitButton" Command="{Binding SubmitCommand}" CommandParameter="{Binding Path=SelectedStory}"  Cursor="Hand" Height="25"  Margin="5 0 0 0">Submit</Button>
    <Button Name="CancelButton" Command="{Binding CloseCommand}" CommandParameter="{Binding Path=SelectedStory}"  Cursor="Hand" Height="25" Margin="5 0 0 0" >Cancel</Button>
 </StackPanel>

删除
提交
取消
我的控制器代码:

    public MetadataController(IGatewayService gateway, IEventAggregator eventAggregator, IDialogService dialog)
    {
        this.gateway = gateway;
        this.eventAggregator = eventAggregator;
        this.dialog = dialog;

        // commands            
        this.CloseCommand = new DelegateCommand<StoryItem>(this.Close);//here i got the exception throwing "the call is ambiguous between the following methods or properties"
        this.DeleteCommand = new DelegateCommand<StoryItem>(this.Delete);
        this.SubmitCommand = new DelegateCommand<StoryItem>(this.Submit, this.HasFieldsRequiredBeforeSubmit);

        this.eventAggregator.GetEvent<StorySelectedEvent>().Subscribe(OnStorySelected);
    }

    private void Close(StoryItem selsectedStory)//when i click my close button its not calling this method at all.
    {
        bool isConfirmed = this.dialog.ShowConfirmation("Are you sure you want to close?");
    }

    private void Delete(StoryItem selectedStory)
    {
        bool isConfirmed = this.dialog.ShowConfirmation("Are you sure you want to permanently delete ?");

        if (isConfirmed)
        {
            this.gateway.DeleteStoryItem(selectedStory);

            this.eventAggregator.GetEvent<CommandCompletedEvent>().Publish(CommandTypes.MetadataEntry);
        }
    }
public MetadataController(IGatewayService网关、IEventAggregator事件聚合器、IDialogService对话框)
{
this.gateway=网关;
this.eventAggregator=eventAggregator;
this.dialog=dialog;
//命令
this.CloseCommand=new DelegateCommand(this.Close);//我在这里遇到了抛出“调用在以下方法或属性之间不明确”的异常
this.DeleteCommand=新的DelegateCommand(this.Delete);
this.SubmitCommand=new DelegateCommand(this.Submit,this.hasfieldsrequired before Submit);
this.eventAggregator.GetEvent().Subscribe(OnStorySelected);
}
private void Close(StoryItem selsectedStory)//当我单击我的关闭按钮时,它根本不调用此方法。
{
bool isConfirmed=this.dialog.ShowConfirmation(“您确定要关闭吗?”);
}
私有无效删除(StoryItem selectedStory)
{
bool isConfirmed=this.dialog.ShowConfirmation(“您确定要永久删除吗?”);
如果(未确认)
{
this.gateway.DeleteStoryItem(selectedStory);
this.eventAggregator.GetEvent().Publish(CommandTypes.MetadataEntry);
}
}

您得到的异常表明它不知道如何访问您试图调用的任何方法/属性。可能还有其他方法或属性也被称为
Close
CloseCommand
,并导致冲突?

异常的原因是,我已经有了该方法,我正在尝试创建一个,这就是它抛出错误的原因。非常感谢帮助人员。

抱歉,忘记更改Close方法,大写字母“C”。在我的代码中是大写字母“C”,但我有一个错误抛出@this.CloseCommand=newdelegateCommand(this.Close)//在这里,我得到了异常抛出“调用在以下方法或属性之间是不明确的”抱歉,我的坏消息,我已经在同一个类中有另一个方法,这就是它抛出该异常的原因,现在它以预期的方式工作