Search code examples
c#wpfxamlwindows-store-apps

Cannot access the TextBox in MainPage.xml.cs file


I am creating a Windows Store Blank application. Following is my code:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="100"></RowDefinition>
        <RowDefinition Height="100"></RowDefinition>
        <RowDefinition Height="700"></RowDefinition>
    </Grid.RowDefinitions>
    <TextBlock Text="Sample Search Application"  Margin="30" FontSize="36" />

    <StackPanel Grid.Row="1" Orientation="Horizontal">
        <TextBox x:Name="txtsearch" Width="200" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="30" TextChanged="txtsearch_TextChanged"></TextBox>
        <Button x:Name="BtnPrint" Content="GetValue" Click="BtnPrint_Click"></Button>
    </StackPanel>
    <StackPanel Grid.Row="2" Orientation="Horizontal">
        <TextBlock x:Name="Result" FontSize="36"></TextBlock>
    </StackPanel>
</Grid>

As you see that I have defined a textbox. But in the cs file I am unable to access this textblock. Following is my cs file snapshot:

enter image description here


Solution

  • Hit F5 and try again. Maybe it is not yet compiled.