以下方法或属性之间的调用不明确 - WPF
Posted
技术标签:
【中文标题】以下方法或属性之间的调用不明确 - WPF【英文标题】:The call is ambiguous between the following methods or properties - WPF 【发布时间】:2012-05-03 23:58:18 【问题描述】:我有一个 WPF 表单,其中包含一些用于保存用户输入、删除和取消的按钮。我试图添加功能,以便每当用户单击取消按钮时,都会弹出一条消息。相反,它会在我的控制器中引发异常:
"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);
【问题讨论】:
抱歉,我的错误已经在同一个类中有另一个方法,这就是它抛出异常的原因,现在它的工作方式符合预期 【参考方案1】:您遇到的异常表明它无法访问您尝试调用的任何方法/属性。也许还有一些其他方法或属性也称为 Close
或 CloseCommand
并导致冲突?
【讨论】:
抱歉,忘记更改关闭方法,大写“C”。在我的代码中,它的大写“C”但我有错误抛出 @this.CloseCommand = new DelegateCommand异常的原因,我确实已经有了该方法,并且我正在尝试创建一个,这就是它抛出该错误的原因。非常感谢您的帮助。
【讨论】:
以上是关于以下方法或属性之间的调用不明确 - WPF的主要内容,如果未能解决你的问题,请参考以下文章
以下方法或属性 MVC、devexpress 之间的调用不明确
以下方法或属性 [ Entity Framework Core ] [ OnModelCreating ] 之间的调用不明确