Create an outer viewmodel, that knows if the user is an administrator or a employee, and then have that have a property that returns a viewmodel depending on the user type.
For example, let's say you have these two viewmodels right now;
public class AdministratorViewmodel {
public string Id {
get { return Guid.NewGuid().ToString(); }
}
}
public class EmployeeViewmodel {
public decimal Salary {
get { return 100.0m; }
}
}
And they have their data templates defined as;
<DataTemplate DataType="{x:Type l:AdministratorViewmodel}">
<DockPanel LastChildFill="True">
<Label DockPanel.Dock="Top" Content="Administrator"/>
<Grid DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Id:"/>
<Label Grid.Column="1" Content="{Binding Path=Id, Mode=OneWay}"/>
</Grid>
</DockPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type l:EmployeeViewmodel}">
<DockPanel LastChildFill="True">
<Label DockPanel.Dock="Top" Content="Employee"/>
<Grid DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Salary:"/>
<Label Grid.Column="1" Content="{Binding Path=Salary, Mode=OneWay}"/>
</Grid>
</DockPanel>
</DataTemplate>
Then you can define another viewmodel;
public class MainViewmodel {
private readonly bool isAdministrator;
public MainViewmodel(bool isAdministrator) {
this.isAdministrator = isAdministrator;
}
public object Content {
get { return isAdministrator ? (object)(new AdministratorViewmodel()) : (object)(new EmployeeViewmodel()); }
}
}
And set let that have a data template as well;
<Window.Resources>
<DataTemplate DataType="{x:Type l:MainViewmodel}">
<DockPanel LastChildFill="True">
<Label DockPanel.Dock="Top" Content="Some sort of parent container"/>
<ContentPresenter DockPanel.Dock="Bottom" Content="{Binding Path=Content, Mode=OneWay}"/>
</DockPanel>
</DataTemplate>
Then, depending on the user type the MainViewmodel will return either an AdministratorViewmodel or an EmployeeViewmodel instance, and the correct data template will be picked by the content presenter;
Hope this helps,
Fredrik