I have a control I 'created' in XAML that I want to access through the Code Behind.
<wincontrols:LiveTileFrameElement Name="PendingAuthsFrame1" Text="Pending" /> this.PendingAuthsFrame1.Text = "334";
However, I get a Build Error on the second statement above stating MyApp.MainWindow does not contain a definition for 'PendingAuthsFrame1' and no extension method....
it keeps going but you get the idea I'm guessing.
What am I missing or doing wrong?
Code-behind is a term used to describe the code that is joined with markup-defined objects, when a XAML page is markup-compiled. This topic describes requirements for code-behind as well as an alternative inline code mechanism for code in XAML.
Controls in WPF are accessed by their names (and the Name property). We specify the Name property in the XAML, and then can access the control by that name directly in C# code. This allows controls to interact. Example.
XAML is a new descriptive programming language developed by Microsoft to write user interfaces for next-generation managed applications. XAML is the language to build user interfaces for Windows and Mobile applications that use Windows Presentation Foundation (WPF), UWP, and Xamarin Forms.
Use x:Name
instead of Name
. That should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With