I need to pass a View’s class name as CommandParameter. How to do this?
<UserControl x:Name="window"
x:Class="Test.Views.MyView"
...>
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.Resources>
<DataTemplate x:Key="tabItemTemplate">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<Button Command="{Binding DataContext.CloseCommand, ElementName=window}"
CommandParameter="{Binding x:Class, ElementName=window}">
</Button>
</StackPanel>
</DataTemplate>
</Grid.Resources>
</Grid>
</UserControl>
The result should be a string ‘Test.Views.MyView’.
x:Class is only a directive and not a property so you won’t be able to bind to it.
From MSDN
But you can get the same result from the FullName property of the Type. Use a Converter
GetTypeFullNameConverter