Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF reference object from XAML

Tags:

wpf

xaml

Here is one that bothers me!

I found on stackoverflow this Accessing XAML object in codebehind(WPF) about accessing a resource.

But what if i want reference to a textbox, for example, in my code-behind file? I didn't find that around.

Thanks!

like image 995
Andr Avatar asked Apr 11 '26 21:04

Andr


1 Answers

Give it an x:Name and then in your code-behind just reference it as this.TheName.

See XAML Named Elements on MSDN.

like image 181
sourcenouveau Avatar answered Apr 14 '26 01:04

sourcenouveau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!