I have this button in my XAML code-
<Button x:Name="button"
Content="{Binding Name}"
Click="Start"
HorizontalAlignment="Left"
Margin="123,45,0,0"
VerticalAlignment="Top"/>
I have another C# code-
namespace MyGame
{
public sealed partial class MainPage : Page
{
public string Name()
{
get{ return "Hello" };
}
private void ButtonNo3(object sender, RoutedEventArgs e)
{
Button obj = (Button)sender;
var selectedButton = obj.Content.ToString();
//This is where I get this error-An exception of type 'System.NullReferenceException' occurred in MyGame.exe but was not handled in user code
}
}
}
My question is how can I get Content
of my Button
in my xaml
code to store the value from the function of C#
code?