Вопрос пользователя:
Ответ нейросети:
Пример кода для создания двух вкладок с использованием TabControl в WPF:
<Window x:Class="TabControlExample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://http://schemas.microsoft.com/winfx/2006/xaml" Title="TabControl Example" Height="350" Width="525"> <Grid> <TabControl> <TabItem Header="Add Question"> <Grid> <TextBox x:Name="questionTextBox" Margin="10" PlaceholderText="Enter question"/> <TextBox x:Name="answer1TextBox" Margin="10" PlaceholderText="Enter answer 1"/> <TextBox x:Name="answer2TextBox" Margin="10" PlaceholderText="Enter answer 2"/> <TextBox x:Name="answer3TextBox" Margin="10" PlaceholderText="Enter answer 3"/> <ComboBox x:Name="correctAnswerComboBox" Margin="10"> <ComboBoxItem Content="Answer 1"/> <ComboBoxItem Content="Answer 2"/> <ComboBoxItem Content="Answer 3"/> </ComboBox> <Button Content="Submit" Click="SubmitButton_Click" Margin="10"/> </Grid> </TabItem> <TabItem Header="Question Table"> <ListView x:Name="questionListView"> <ListView.View> <GridView> <GridViewColumn Header="Question" DisplayMemberBinding="{Binding Question}"/> <GridViewColumn Header="Answer 1" DisplayMemberBinding="{Binding Answer1}"/> <GridViewColumn Header="Answer 2" DisplayMemberBinding="{Binding Answer2}"/> <GridViewColumn Header="Answer 3" DisplayMemberBinding="{Binding Answer3}"/> <GridViewColumn Header="Correct Answer" DisplayMemberBinding="{Binding CorrectAnswer}"/> </GridView> </ListView.View> </ListView> </TabItem> </TabControl> </Grid> </Window>
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
namespace TabControlExample
{
public partial class MainWindow : Window
{
public ObservableCollection<Question> Questions { get; set; }
public MainWindow()
{
InitializeComponent();
Questions = new ObservableCollection<Question>();
questionListView.ItemsSource = Questions;
}
private void SubmitButton_Click(object sender, RoutedEventArgs e)
{
Question newQuestion = new Question
{
QuestionText = questionTextBox.Text,
Answer1 = answer1TextBox.Text,
Answer2 = answer2TextBox.Text,
Answer3 = answer3TextBox.Text,
CorrectAnswer = correctAnswerComboBox.SelectedItem.ToString()
};
Questions.Add(newQuestion);
}
}
public class Question
{
public string QuestionText { get; set; }
public string Answer1 { get; set; }
public string Answer2 { get; set; }
public string Answer3 { get; set; }
public string CorrectAnswer { get; set; }
}
}
Этот пример создает две вкладки: на первой вкладке пользователь может вводить вопросы и ответы, после чего они добавляются в список вопросов и отображаются на второй вкладке в виде таблицы.
Напишите нам, если в вопросе есть ваши персональные данные ([email protected])
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.