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

  • Home
  • SEARCH
  • 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 3754168
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:30:14+00:00 2026-05-19T09:30:14+00:00

I need to be able to pass an unique commands to the hyperlinks that

  • 0

I need to be able to pass an unique commands to the hyperlinks that generated from XML in a DataGrid.

I have commands in the code behind that work if I point them directly to the hyperlinks this way.

<Hyperlink Style="{DynamicResource DataGridCellStyleHyperlink}" Command="{x:Static local:MainWindow.LaunchFirstCommand}">   

I need to do similar but assigning different commands to each hyperlink inside cells dynamically. All hyperlinks are generated from XML. I belive I need to have some sort of converter that will do it. I have trouble making it work. Any advice is highly appreciated. Thank you in advance.

Here is XMLDataProdider code that generates content inside DataGrid. I tried to pass ‘Command’ value as a string:

<XmlDataProvider x:Key="MoreInfoDataGridLocal" XPath="MoreInfoTiles/Servers">
       <x:XData> 
        <MoreInfoTiles xmlns="">
         <Servers Name="Test1" Status="003" Name2="Connection 2" Status2="assigned" />
             <Servers Name="Test2" Status="Not activated" Name2="Address" Status2="test" />
             <Servers Name="Test3" Status="Disabled" Name2="Address" Status2="None" Command="x:Static local:MainWindow.LaunchFirstCommand"/>
        </MoreInfoTiles>
       </x:XData>
  </XmlDataProvider>

I can successfully generate the text strings but command is not doing anything. Below is the code where I hook it up to the hyperlink in datagrid:

<DataGridTemplateColumn>   
<DataGridTemplateColumn.CellTemplate>     
    <DataTemplate>       
        <TextBlock >         
            <Hyperlink Style="{DynamicResource DataGridCellStyleHyperlink}" Command="{Binding XPath=@Command}" >           
                <TextBlock Text="{Binding XPath=@Status}" />                                                   
            </Hyperlink>                         
        </TextBlock>     
    </DataTemplate>   
    </DataGridTemplateColumn.CellTemplate>             
</DataGridTemplateColumn>
  • 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-05-19T09:30:15+00:00Added an answer on May 19, 2026 at 9:30 am

    Yes, you will need to use an IValueConverter to translate the string to a command object. Your Command Binding will look like this:

    Command="{Binding XPath=@Command, Converter={StaticResource MyStringToCommandConverter}}"
    

    and you will need an instance of the converter created as a resource:

    <MyStringToCommandConverter x:Key="MyStringToCommandConverter"/>
    

    Other than that you just need to create the MyStringToCommandConverter (or whatever you name it) class implementing IValueConverter and in the Convert method translate the “value” string into one of your Routed Commands. A simple converter would look something like this:

    public class MyStringToCommandConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string commandType = value as String;
            if (commandType == "LaunchFirstCommand")
                return MainWindow.LaunchFirstCommand;
            if (commandType == "OtherCommand")
                return MainWindow.OtherCommand;
            return null;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to pass XML to a RESTFul WCF service as
I basically need to be able to pass through a $q that is a
I have a TCP client-server setup where I need to be able to pass
I need to be able to pass HTML data into Outlook like this: MailMessage
I am working on an algorithm, and I need to be able to pass
I am able to pass a variable forward from view controller to view controller
I'm working on an application where I need to be able to pass a
I need to have a button style that will present 3 different texts of
I need to be able to pass along two objects to the method being
Need to be able to pass a single quote in the string Cmm'l so

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.