Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7996767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:47:17+00:00 2026-06-04T14:47:17+00:00

I need to pass a View’s class name as CommandParameter. How to do this?

  • 0

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’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:47:18+00:00Added an answer on June 4, 2026 at 2:47 pm

    x:Class is only a directive and not a property so you won’t be able to bind to it.

    From MSDN

    Configures XAML markup compilation to join partial classes between
    markup and code-behind. The code partial class is defined in a
    separate code file in a Common Language Specification (CLS) language,
    whereas the markup partial class is typically created by code
    generation during XAML compilation.

    But you can get the same result from the FullName property of the Type. Use a Converter

    CommandParameter="{Binding ElementName=window,
                               Path=.,
                               Converter={StaticResource GetTypeFullNameConverter}}"
    

    GetTypeFullNameConverter

    public class GetTypeFullNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return null;
            }
            return value.GetType().FullName;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://something.php?ownerID=13&view=userAgreement i need to pass two variables to this .. how can i pass
I need to pass a list of Days (number and name) to an view!
i need to pass data to my view. my ActionResult is this public ActionResult
I have a view that contains many partial views and I need to pass
I need to pass a url string from the view to the controller, a
I need to pass a variable to my view with Time.now + @seconds in
I need to pass some variables from a controller to its view or to
I Use MVC and sometimes need to pass the ViewBag.Message from Controller to view,
I need to pass the value to jQuery in the view using viewbag. What
I have the need to pass the current model of the view, from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.