嗨,我試圖讓一個Silverlight頁面,在視圖模型的事件,但我不知道如何做到這一點的頁面加載事件(我無法找到正確的命令)。 我想結合這樣的:加載=「RadPane_Loaded」到加載= {結合RadPane_Loaded}。Silverlight的模型,視圖 - 視圖模型煩惱
查看:
namespace SilverlightTest.Modules.Tree
{
public partial class OutlookBarView : RadPane
{
public OutlookBarView(OutlookBarViewModel model)
{
InitializeComponent();
DataContext = model;
}
}
}
視圖模型:
namespace SilverlightTest.Modules.Tree
{
public class OutlookBarViewModel : DependencyObject
{
private IEventAggregator _eventAggregator;
private IMainPage _shell;
private IUnityContainer _container;
public OutlookBarViewModel(IEventAggregator eventAggregator, IMainPage shell, IUnityContainer container)
{
_container = container;
_eventAggregator = eventAggregator;
_shell = shell;
}
This is what I would normally do to bind something to a control.
public ICommand ExampleCommand
{
get { return (ICommand)GetValue(ExampleCommandProperty); }
set { SetValue(ExampleProperty, value); }
}
/* Here I'd like to bind the page load event but I don't understand how...? */
}
}
嘿弗拉基米爾非常感謝你。這對我來說是非常有用的信息:D這是執行此操作的標準Silverlight方式還是有替代方法?我想知道這是因爲這個功能不在標準的Silverlight程序集中。 – BigChief 2011-04-10 22:12:41
是的,如果您想使用MVVM模式,這是標準方式。這些程序集將在Silverlight 5的核心中可用,但現在它們提供了Blend SDK – 2011-04-11 07:04:55