This is a project for Windows Phone 8.
I have tried using a XamlReader to load a Grid containing several objects, one of which is a button. The button can be created fine, found, and attached a handler in c#, but does not seem to respond to clicks - the button doesn't change colour when pressed, and no associated handlers are called.
The XAML being read by XamlReader is
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name = "testgrid" Background = "Transparent">
<Button x:Name="btn" Content="Button" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="0,0,0,0" Grid.Row="1" Height="81"/>
<TextBlock Text = "Test"/>
</Grid>
The c# code used is
Grid tGrid = (Grid)XamlReader.Load(xaml);
Button tgtButton = (Button)tGrid.FindName("btn");
LayoutRoot.Children.Add((UIElement)tGrid);
tgtButton.Content = "bloop";
What could be the problem here? Thanks!
p.s. If the loaded xaml is a button only, using the same method to add it to the LayoutRoot, it does respond to pressing.