I had the same problem a couple of days ago... and I have found a solution... I am not very proud of it but it works..
create a datatemplate and add there all the possible usercontrols
<DataTemplate x:Key="WorkspaceItemTemplate">
<Grid>
<View:TreeView Visibility="{Binding Converter={StaticResource ViewVisibilityConverter}, ConverterParameter=TreeView}" />
<View:GridView Visibility="{Binding Converter={StaticResource ViewVisibilityConverter}, ConverterParameter=GridView}" />
<View:DataView Visibility="{Binding Converter={StaticResource ViewVisibilityConverter}, ConverterParameter=DataView}" />
</Grid>
</DataTemplate>
and create a convertor that changes visibility based on type
public class ViewVisibilityConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (((ViewModelBase)value).DisplayName.Equals((string)parameter))
return Visibility.Visible;
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}