[英]Silverlight 2 and the MVP Pattern
Any ideas on how i get MVP working with Silverlight? 关于如何使MVP与Silverlight协同工作的任何想法? How Do I get around the fact there is no load event raised?
我如何解决没有引发负载事件的事实?
This the view I have: 这个观点我有:
public partial class Person: IPersonView
{
public event RoutedEventHandler Loaded;
public Person()
{
new PersonPresenter(this);
InitializeComponent();
}
public Person Person
{
set { Person.ItemsSource = value; }
}
}
And my presenter: 而我的主持人:
public class PersonPresenter
{
private readonly IPersonView _view;
private readonly ServiceContractClient _client;
public PersonPresenter(IPersonView view)
{
_client = new ServiceContractClient();
_view = view;
WireUpEvents();
}
private void WireUpEvents()
{
_view.Loaded += Load;
}
private void Load(object sender, EventArgs e)
{
_client.GetPersonCompleted += Client_GetPerson;
_client.GetPersonAsync();
}
private void Client_GetPerson(object sender, GetPersonCompletedEventArgs e)
{
_view.Person= e.Result;
}
}
Nothing happened for me as the Loaded event dont seem to get called, how do i get around this? 没有发生任何事情,因为Loaded事件似乎没有被调用,我该如何解决?
Tim Ross通过源代码很好地介绍了Silverlight MVP实现。
I believe the loaded event gets called when the control has been initialized, loaded, rendered and ready for use. 我相信在控件已初始化,加载,呈现并准备使用时,将调用load事件。 This means that as long as you don't place it inside a visible container (so that it is rendered), the loaded event won't be risen.
这意味着只要您不将其放置在可见的容器中(以便呈现),就不会引发已加载的事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.