InitializeComponent()之间的调用;暧昧吗?

时间:2013-07-31 23:17:07

标签: c# windows-phone

我的错误是:

  

错误4以下方法或属性之间的调用不明确:'Grub2._0.Time.InitializeComponent()'和   'Grub2._0.Time.InitializeComponent()'

这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace Grub2._0
{
    public partial class Time2 : PhoneApplicationPage
    {
        public void Time2.()
        {
            InitializeComponent();
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (AMRadioButton.IsChecked == true)
                NavigationService.Navigate(new Uri("/PolicemanFood.xaml", UriKind.Relative));
            else if (PMRadioButton.IsChecked == false)
                NavigationService.Navigate(new Uri("/Weed.xaml", UriKind.Relative));
            else
                NavigationService.Navigate(new Uri("/BurgerKing.xaml", UriKind.Relative));
        }
    }
}

1 个答案:

答案 0 :(得分:0)

试试这段代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace Grub2._0
{
    public partial class Time2 : PhoneApplicationPage
    {
        public Time2()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (AMRadioButton.IsChecked == true)
                NavigationService.Navigate(new Uri("/PolicemanFood.xaml", UriKind.Relative));
            else if (PMRadioButton.IsChecked == false)
                NavigationService.Navigate(new Uri("/Weed.xaml", UriKind.Relative));
            else
                NavigationService.Navigate(new Uri("/BurgerKing.xaml", UriKind.Relative));
        }
    }
}

在构造函数的Time2之后删除了 void 关键字和句点。