Я пытаюсь показать текст в текстовом поле в WPF.
, вот как я добавил текстовое поле в xml:
<TextBox x:Name="textBoxLine1" HorizontalAlignment="Left" Height="22" Margin="29,30,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
для раздела C# код:
public string getLine1()
{
return this.textBoxLine1.Text;
}
Что этот код делает: для считывателя паспортов он читает MRZ и отображает его в TextBox. textBoxLine1
не отображается с чтением и выдает ошибку ниже.
"FormMRZ" doesnot contain a definition for "textBoxLine1" and no accessible extension method "textBoxLine1" accepting a first argument of type "FormMRZ" could be found
Как я могу исправить эту ошибку? Я ценю вашу помощь.
Обновление:
Мой полный XML код:
<Page x:Class="WpfApp1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Page1">
<Grid x:Name="Passport" Background="White">
<TextBox Name="textBoxLine1" HorizontalAlignment="Left" Height="22" Margin="29,30,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox Name="textBoxLine2" HorizontalAlignment="Left" Height="23" Margin="29,57,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<TextBox Name="textBoxLine3" HorizontalAlignment="Left" Height="22" Margin="29,90,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
</Grid>
</Page>
Мой класс FormMRZ:
public partial class FormMRZ : Form
{
private int nbLines;
public FormMRZ()
{
}
public string MRZInfo, docNumDigit;
public string getLine1()
{
return this.textBoxLine1.Text;
}
public string getLine2()
{
return this.textBoxLine2.Text;
}
public string getLine3()
{
return this.textBoxLine3.Text;
}
}
Это не полный код FormMRZ.