0

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.

Nikh
  • 27
  • 6
  • You can do this pretty easy with only xaml and an event trigger, but would you want the change to be permanent? As in if they click it once, then the condition is met and it will remain saying "Do not click me!" or do you mean to have it reversible with another click by using a `ToggleButton` instead? – Chris W. Jan 30 '14 at 18:58
  • Thank you for your suggestion. I want it to be permanent and my whole point is "How to pass variables from .xaml.cs to .xaml"... How can I use the "event trigger" for this purpose? – Nikh Jan 30 '14 at 19:02
  • This question appears to be off-topic because it does not show a basic level of understanding of programming. – Ian Ringrose Feb 08 '14 at 10:52
  • Hi lan Ringrose, You have a professional understanding of programming which is very good But I would like to let you know I am doing my masters and I have been programming in the past 9 years. I am new to silverlight and faced this issue. I do not know if this is a bug or not but it does not work and this is what it is... Thank you very much – Nikh Feb 10 '14 at 20:59

1 Answers1

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

should be

buttonname.Content = "Do not click on me!";
Gerrit Fölster
  • 984
  • 9
  • 18