A
A
Alexander Shipin2022-03-01 09:59:39
WPF
Alexander Shipin, 2022-03-01 09:59:39

How to change the contents of a Label inside a Page using Window buttons?

Given:
1. A window with the MainWindow class
2. Inside the window there is a Frame element that is responsible for rendering the necessary page (for example, AboutPage), and there are also two buttons
- the first ShowPageButton is responsible for rendering the Page (roughly performs Frame.Content = new AboutPage())
- the second ChangeLabelButton is responsible for changing the Label (performs, roughly, TestText.Content = "Some test text
"

)
change the contents of the TestText by clicking on the ChangeLabelButton button?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shipin, 2022-03-24
@alexshipin

Everything turned out to be simple:

private void ChangeLabelButton_Click(object sender, RoutedEventArgs e) {
    // ... другой выполняемый код
    Frame.Refresh();
    // ... другой выполняемый код
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question