开发者

Caliburn and datatemplates in Silverlight 3

Does anyone know if the same functionality for displaying views depending on object/viewmodel is applicable to Silverlight 3?

Like this:

<Application.Resources>
<开发者_运维技巧DataTemplate DataType="{x:Type vm:CustomerViewModel}">
    <view:CustomerView />
</DataTemplate>

<ContentControl Content="{Binding Path=CurrentView}"/>

            public class RootViewModel : BaseViewModel

{

private BaseViewModel _currentView;
public BaseViewModel CurrentView

{
    get { return _currentView; }
    set
    {
        _currentView = value;
        RaisePropertyChanged("CurrentView");
    }
}
public void ShowCustomer()
{
    CurrentView = IoC.Resolve<Customerviewmodel>();
}

}

Sorry about the formatting. Can't seem to get it right...

/Johan


If you are using Caliburn, you can use the View.Model attached property on your ContentControl to achieve this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜