Silverlight 3 中的 Caliburn 和数据模板
有谁知道根据对象/视图模型显示视图的相同功能是否适用于 Silverlight 3?
像这样:
<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>();
}
}
抱歉,格式不正确。似乎不太对劲……
/约翰
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是 Caliburn,则可以使用 ContentControl 上的 View.Model 附加属性来实现此目的。
If you are using Caliburn, you can use the View.Model attached property on your ContentControl to achieve this.