How to set a text in textblock defined xaml using c#. I am redirecting to a phone page where I have a stackpanel and couple of textblocks inside. If I name a text block and call it in the c# code, it is not working. How to set the string in the text block when the page is loaded... And the text is passed from the previous page. Basically the textblock in not recognised... How to make it visible in c# code...
XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="16,0,12,0">
<StackPanel x:Name="activationPanel" Margin="0,10">
<TextBlock TextWrapping="Wrap" Text="Almost there !" FontFamily="Segoe UI" FontWeight="Light" FontSize="24" Foreground="#FF486070"/>
<TextBlock TextWrapping="Wrap" Text="An activation mail has been sent" FontFamily="Segoe UI" FontWeight="Light" FontSize="24" Foreground="#FF486070" Margin="0,18,0,0"/>
<TextBlock Name="useremail" TextWrapping="Wrap" FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="24" Foreground="#FF486070" Margin="0,10,0,0" LostFocus="useremail_LostFocus"/>
<TextBlock TextWrapping="Wrap" Text="please click on the link to activate your account" FontFamily="Segoe UI" FontWeight="Light" FontSize="24" Foreground="#FF486070" Margin="0,50,78,0"/>
<Button x:Name="btnAcA" Content="ACCOUNT ACTIVATED" Width="335" HorizontalAlignment="Left" Height="42" Padding="12,0,10,0" Background="#FF55D782" BorderBrush="{x:Null}" BorderThickness="0" FontSize="16" FontFamily="Segoe UI" Style="{StaticResource LoginButtonStyle}" Margin="0,90,0,25" Click="btnAcA_Click"/>
<Button x:Name="btnRAM" Content="RESEND ACTIVATION MAIL" Width="335" HorizontalAlignment="Left" Height="42" Padding="12,0,10,0" Background="#FF637A8A" BorderBrush="{x:Null}" BorderThickness="0" FontSize="16" FontFamily="Segoe UI" Style="{StaticResource LoginButtonStyle}" Margin="0,0,0,25"/>
</StackPanel>
</Grid>
C#:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string email=null;
if (this.NavigationContext.QueryString.ContainsKey("email"))
{
email = this.NavigationContext.QueryString["email"];
}
Debug.WriteLine(email);
setTextBoxValue(email);
}
private void setTextBoxValue(string email)
{
//TextBlock useremail = new TextBlock();
useremail.Text = email;
}