showing dynamic text in silverlight

爷,独闯天下 提交于 2019-12-02 19:16:57

问题


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.


回答1:


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

should be

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


来源:https://stackoverflow.com/questions/21465011/showing-dynamic-text-in-silverlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!