0

我是 WPF 新手,想学习 WPF 复合应用程序。
我有用户控制,这是一个模块,上面有 1 个标签和 1 个按钮。
现在我正在尝试在按钮上使用 Command 属性,看起来像

<Button Name="button1" Command="{Binding Path = GetCustomerNameCommand}">GetCustomer</Button>

在演示者中,我得到了

public class HelloWorldPresenter : PresenterBase<IHelloWorldView>
    {
        private readonly IWpfService _wpfService;

        public HelloWorldViewModel CustomerViewModel { get; set; }

        public ICommand GetCustomerNameCommand { get; set; }

        public HelloWorldPresenter(IHelloWorldView view, IWpfService wpfService)
            : base(view)
        {
            _wpfService = wpfService;

            GetCustomerNameCommand = new DelegateCommand<string>(GetCustomerName);
            View.Presenter = this;

            PopulateViewModel(string.Empty);
        }

        private void GetCustomerName(string obj)
        {
            throw new NotImplementedException();
        }

        private void PopulateViewModel(string test)
        {
            CustomerViewModel = new HelloWorldViewModel { Name = _wpfService.GetCustomer() };
        }
    }

问题是当我单击按钮时 GetCustomerName() 方法没有被执行

4

1 回答 1

0

我找到了,我添加了 2 次相同的视图,这导致了问题......

于 2010-06-25T09:07:21.653 回答