I want to Implement MVP pattern. I have a user control that has some Textboxes and when I put it in form I call a method from usercontrol and fill textboxes. But in mvp patt
Here is an example implementation of the pattern. The Presenter only knows about the interface having a show method. The Presenter calls it, but the only the form (aka View) implements how the form should be displayed.
public interface IMyFormView {
void Show();
}
public class MyForm : IMyFormView {
public MyForm() {
var presenter = new MyFormPresenter(this);
presenter.Init();
}
public void Show() {
usercontrol1.fill();
}
}
public class MyFormPresenter
{
private IMyView _view;
public MyFormPresenter(IMyView view) {
_view = view;
}
public void Init() {
_view.Show();
}
}
If you need to pass data into the view, then you can pass a view model through the Show-method or set custom Properties on the view.