A
A
Alikhan2021-11-14 19:08:02
WPF
Alikhan, 2021-11-14 19:08:02

How to change the content of a XAML tag via C# WPF?

How to change the content of a XAML tag via C# WPF? That is, let's add a nested tag to it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ertanic, 2021-11-16
Mulaev @AlikhanPython

As far as I remember, you can add the x:Name="name" attribute, which will automatically generate a namespace member with the same name.
That is, for example, there is a button: And in the code: There is also an id attribute, but there is a problem with getting and then ghosting the type. I don't remember this way yet... But as far as I know, it's bad practice within WPF. It is better to use the built-in WPF features: events, commands.
<Button x:Name="btn1"/>
btn1.Value = "Hello, World!";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question