0

我的错误是:

错误 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));
        }
    }
}
4

1 回答 1

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关键字和句点。

于 2013-07-31T23:25:40.540 回答