Question

I have a button which shows "click me!" on it. I want to see that when I click on the button, it shows "Do not click on me!"

I have a button in my Search.xaml file like below and it always show "click me!".

<Button x:Name="buttonname" Canvas.Top="60" Canvas.Left="30" Click="btnTest_Click" Content="click me!"></Button>

Also my Search.xaml.cs looks like below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace TMTemplate
{
    public partial class Search : Page
    {
        public Search() { 
            InitializeComponent();
        }
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            this.Content = "Do not click on me!";
        }   
    }
}

This is not working and I have spent lots of time to figure this out, Would you please let me know how I can get it working...

Thank you so much.

No correct solution

OTHER TIPS

this.Content = "Do not click on me!";

should be

buttonname.Content = "Do not click on me!";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top