windows phone应用程序按钮内容

时间:2015-04-21 17:35:25

标签: windows windows-phone-7

我有一个非常奇怪的问题。我在Windows手机上制作备忘录游戏应用程序。当我点击2个按钮时,如果它们具有相同的内容,则应该折叠。问题是,即使它们具有相同的内容,例如1,它也告诉我这个陈述是错误的!像1不等于1。

以下是代码:

public partial class Memo : PhoneApplicationPage
{
    private int points = 100;
    private string[] numbers={"a","a"};
    private Button selected_button;

    public Memo()
    {
        InitializeComponent();

        button1.Content = numbers[0];
        button2.Content = numbers[1];
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        if (selected_button != null)
        {
            PageTitle.Text = "" + selected_button.Content + " " + button1.Content;
            if (selected_button.Content == button1.Content)
            {
                button1.Visibility = Visibility.Collapsed;
                selected_button.Visibility = Visibility.Collapsed;
                points += 3;
            }
            else
            {
                points -= 1;
                selected_button.Background = new SolidColorBrush(Colors.White);
            }

            selected_button = null;
            //PageTitle.Text = "" + points;
        }
        else
        {
            selected_button = button1;
            selected_button.Background = new SolidColorBrush(Colors.Green);
        }
    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
        if (selected_button != null)
        {
            PageTitle.Text = "" + selected_button.Content + " " + button2.Content;
            if (selected_button.Content == button2.Content)
            {
                button2.Visibility = Visibility.Collapsed;
                selected_button.Visibility = Visibility.Collapsed;
                points += 3;
            }
            else
            {
                points -= 1;
                selected_button.Background = new SolidColorBrush(Colors.White);
            }
            selected_button = null;
            //PageTitle.Text = "" + points;
        }
        else
        {
            selected_button = button2;
            selected_button.Background = new SolidColorBrush(Colors.Green);
        }
    }

    private void button11_Click(object sender, RoutedEventArgs e)
    {
        button11.Visibility = Visibility.Collapsed;
    }
}

请帮助:)

0 个答案:

没有答案