title: Programatically setting the Name attribute for WPF Elements
body: <p>I'm writing tests using WiPFlash for a WPF application that has been developed in our office.  In order to do this I have had to add name attributes to several of WPF components that up until now have not needed them.  </p>
  
  <p>I have hit a block though in trying to set unique names to a set of objects that are created at runtime.  The XAML looks like: </p>
  
  <pre><code>&lt;UserControl x:Class="Atlas.Activities.RibbonActivity.RibbonActivityView" 
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                       xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
                       xmlns:RoutedMessaging="clr-namespace:Caliburn.PresentationFramework.RoutedMessaging;assembly=Caliburn.PresentationFramework" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"&gt;
  
  &lt;ribbon:RibbonButton Style="{StaticResource RibbonButtonView}" Name="RibbonActivity"&gt;
      &lt;ribbon:RibbonButton.ContextMenu&gt;
          &lt;ribbon:RibbonContextMenu&gt;
              &lt;ribbon:RibbonMenuItem x:Name="Modify" Header="Modify..." RoutedMessaging:Message.Attach="[Event Click] = [Action Modify]" /&gt;
              &lt;ribbon:RibbonMenuItem x:Name="Hide" Header="Hide" RoutedMessaging:Message.Attach="[Event Click] = [Action Hide]" /&gt;
              &lt;ribbon:RibbonMenuItem x:Name="Delete" Header="Delete" RoutedMessaging:Message.Attach="[Event Click] = [Action Delete]" /&gt;
          &lt;/ribbon:RibbonContextMenu&gt;
      &lt;/ribbon:RibbonButton.ContextMenu&gt;
  &lt;/ribbon:RibbonButton&gt;
  </code></pre>
  
  <p></p>
  
  <p>The constructor set the subject using:</p>
  
  <pre><code>WithSubject(activity);
  </code></pre>
  
  <p>which is inhereted from Caliburn.PresentationFramework.Screens.</p>
  
  <p>So what I want to do is set the name of each control to be the name field within the subject (activity).  </p>
  
  <p>Can anyone help me out, or at least let me know if this is possible, </p>
  
  <p>Thanks in advance, </p>
  
  <p>Klee. </p>