Question : How to find focused control in Silverlight

I'm writing copy / paste functionality to a silverlight project. My project contains multiple pages, TextBox objects etc.

Now user wants to copy and paste selected text.

My problem is that I can't find which object has focus and without that information it is hard to copy text.

My xaml page has a grid which contains some user controls in different cells. The main grid handles right mouse menu with copy/paste functionality.

Since I am not working with WinForms, but in Silverlight. How can I find focused control?

Here are some code snippets:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
<!-- Right mouse click opens copy/paste menu -->
<!-- Left mouse click just closes it -->
<Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded" 
MouseRightButtonDown="LayoutRoot_MouseRightButtonDown"
        MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown">

<!-- Here are lots of elements created -->  

      <Canvas>
        <Popup x:Name="ContextMenu" Visibility="Collapsed" MouseRightButtonDown="LayoutRoot_MouseLeftButtonDown">
            <Border CornerRadius="5" BorderBrush="White" BorderThickness="1" Background="LightGray">
                <StackPanel >
                    <Button Content="Copy" Foreground="Black" Click="CopySelectedContent" />
                    <Button Content="Paste" Foreground="Black" Click="PasteFromClipboard" />
                </StackPanel>
            </Border>
        </Popup>
    </Canvas>
</Grid>

<!-- In code beside file there is a event handler -->
private void LayoutRoot_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    // I'd perefer capturing focused control here - before right mouse menu (canvas) is opened.
    // But sender is Grid hosting this canvas.
    Point position = e.GetPosition(null);
    e.Handled = true;
    ContextMenu.Visibility = Visibility.Visible;
    ContextMenu.IsOpen = true;
    ContextMenu.SetValue(Canvas.LeftProperty, (double)position.X);
    ContextMenu.SetValue(Canvas.TopProperty, (double)position.Y);  
}

Answer : How to find focused control in Silverlight

Take out the javascript onclick and make it an "HREF=" then within the a tag set the target='_new' and it will open as a new window.

<a HREF="EditMetric.aspx?sid=" & myDataTable.Rows(0)(1) & "&kpName=" & myDataTable.Rows(0)(0) & """, """", ""fullscreen=yes scrollbars=yes"");' " _
                         & "style='text-decoration:underline;cursor:hand;' target='_new'>
Random Solutions  
 
programming4us programming4us