views:

177

answers:

1

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

A: 

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

EisenbergEffect
Do you have a simple example??
Johan Zell

related questions