'Textbox has text in it, but text property = ""; VISUAL STUDIOS WPF C#

My textbox element looks like this:

<TextBox x:Name="NameTextbox" Style="{DynamicResource Button_No_Light_TextBox_Black}" TabIndex="0"/>

The styling for the text box is this:

        <Setter Property="Text" Value=""/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <TextBox Padding="15,0,0,0" FontFamily="Sitka Small" Height="50" VerticalContentAlignment="Center" Background="Black" Foreground="Red" BorderBrush="Black" HorizontalAlignment="Left" Margin="30,0,0,0" FontSize="20" TextWrapping="Wrap"  BorderThickness="0" Width="640">
                        <TextBox.Resources>
                            <Style TargetType="{x:Type Border}">
                                <Setter Property="CornerRadius" Value="5"/>
                            </Style>
                        </TextBox.Resources>
                    </TextBox>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="Black"/>
                            <Setter Property="BorderBrush" Value="Black"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

In my CS file, I have written

 private void Create_Account_Button_Click(object sender, RoutedEventArgs e)
        {
            string name = NameTextbox.Text;
            string email = EmailTextbox.Text;
            string password = PasswordGrid.pb.Password;
            Account newAccount = new Account(name, email, password);   
        }; 

but name is equal to "".

The same applies to email.

Image of Problem



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source