title: How to override the hyperlink string value generated from XML in DataGrid?
body: <p>I have a scenario where I need to change the name of the hyperlink in datagrid after checking a RadioButton that resides in separate “Options” window. I launch this “Option” Window using ICommand that assigned to the same hyperlink. I have trouble renaming the hyperlink name. The hyperlinks are generated from XML using XMLDataProvider. I also use IValueConverter that converts XML string to ICommand. I hope to find solution here. Thank you in advance. </p>
  
  <p>Link to the testing solution:
  <a href="http://cid-0c29483cf3a6a14d.office.live.com/self.aspx/WPF%5E_Tests/RenameHyperlinkText.zip" rel="nofollow">http://cid-0c29483cf3a6a14d.office.live.com/self.aspx/WPF%5E_Tests/RenameHyperlinkText.zip</a></p>
  
  <p>Code below.</p>
  
  <p>Generating dataGrid with hyperlinks XAML in Main Window:</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;local:MyStringToCommandConverter x:Key="MyStringToCommandConverter"/&gt;
      &lt;XmlDataProvider x:Key="MainDataGridLocal" XPath="ServicesTiles/Servers"&gt;
          &lt;x:XData&gt;
              &lt;ServicesTiles xmlns=""&gt;
                &lt;Servers Name="Name 1" Status="None" Name2="Name 2" Status2="Never" Command="LaunchOptionsWindowCommand" /&gt;
                &lt;Servers Name="Name 3" Status="none"  Name2="Name 4" Status2="None" /&gt;
              &lt;/ServicesTiles&gt;
          &lt;/x:XData&gt;
      &lt;/XmlDataProvider&gt;
  &lt;/Window.Resources&gt; 
  &lt;Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource MainDataGridLocal}}"&gt;
      &lt;DataGrid x:Name="MainGrid" AutoGenerateColumns="False" ItemsSource="{Binding XPath=/ServicesTiles/Servers}"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Binding="{Binding XPath=@Name}" /&gt;  
              &lt;DataGridTemplateColumn &gt;     
                  &lt;DataGridTemplateColumn.CellTemplate&gt;         
                      &lt;DataTemplate&gt;             
                          &lt;TextBlock &gt;
                              &lt;Hyperlink Command="{Binding XPath=@Command, Converter={StaticResource MyStringToCommandConverter}}" &gt;                
                                      &lt;TextBlock Text="{Binding XPath=@Status}" /&gt;
                              &lt;/Hyperlink&gt;
                          &lt;/TextBlock&gt;         
                      &lt;/DataTemplate&gt;     
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;                          
              &lt;/DataGridTemplateColumn&gt; 
              &lt;DataGridTextColumn Binding="{Binding XPath=@Status2}"/&gt;
              &lt;DataGridTemplateColumn &gt;     
                  &lt;DataGridTemplateColumn.CellTemplate&gt;         
                      &lt;DataTemplate&gt;             
                          &lt;TextBlock &gt;
                              &lt;Hyperlink &gt;                   
                                  &lt;TextBlock Text="{Binding XPath=@Status2}" /&gt;
                              &lt;/Hyperlink&gt;
                          &lt;/TextBlock&gt;         
                      &lt;/DataTemplate&gt;     
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;                          
              &lt;/DataGridTemplateColumn&gt; 
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Code behind to run command:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
  
  public static RoutedUICommand OptionsWindowCommand = new RoutedUICommand("Options...", "Options", typeof(MainWindow));
  
      public MainWindow()
      {
          this.InitializeComponent();
          this.CommandBindings.Add(new CommandBinding(OptionsWindowCommand, OptionsWindowCommandExecuted));
      }
      private void OptionsWindowCommandExecuted(object sender, ExecutedRoutedEventArgs e)
      {
          OptionsWindow theDialog = new OptionsWindow();
          if ( theDialog != null )
              theDialog.ShowDialog();
      }
  }
  </code></pre>
  
  <p>OptionsWindow XAML with RadioButtons and OK button:</p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Height="250" VerticalAlignment="Top"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Button Content="Cancel" VerticalAlignment="Bottom" Margin="0,0,20,0" OpacityMask="#FFE0DADA" IsCancel="True" HorizontalAlignment="Right" Width="75"/&gt;
      &lt;Button Content="OK" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,0,103.06,0" IsDefault="True" /&gt;
      &lt;StackPanel HorizontalAlignment="Center"  Width="158" VerticalAlignment="Center"&gt;
          &lt;RadioButton x:Name="a_RD" Content="1_RD" Height="25"/&gt;
          &lt;RadioButton x:Name="b_RD" Content="2_RD;" IsChecked="True" Height="25"/&gt;
          &lt;RadioButton x:Name="c_RD" Content="3_RD" Height="25"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>