4 Replies - 686 Views - Last Post: 24 August 2014 - 03:42 AM Rate Topic: -----

#1 andynov123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 24-May 11

RadioButton.Checked not working

Posted 31 July 2014 - 06:24 PM

How would I change the following code with a radio button so that I can put an if statement like if(easyMode.Checked){} because it's not working when I assigned it to RadioButton. The code I'm referring to is in MathTime Function on second page.

First Page

    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;
    using FinalProjectPhoneVersion.Resources;
    
    namespace FinalProjectPhoneVersion
    {
    
        public partial class MainPage : PhoneApplicationPage
        {
            static int strikeCounter;
            static int counter;
            static Random random = new Random();
    
            static int randomNumber1;
            static int randomNumber2;
           
            // Constructor
            public MainPage()
            {
                InitializeComponent();
    
                // Sample code to localize the ApplicationBar
                //BuildLocalizedApplicationBar();
            }
    
            // Sample code for building a localized ApplicationBar
            //private void BuildLocalizedApplicationBar()
            //{
            //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
            //    ApplicationBar = new ApplicationBar();
    
            //    // Create a new button and set the text value to the localized string from AppResources.
            //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
            //    appBarButton.Text = AppResources.AppBarButtonText;
            //    ApplicationBar.Buttons.Add(appBarButton);
    
            //    // Create a new menu item with the localized string from AppResources.
            //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
            //    ApplicationBar.MenuItems.Add(appBarMenuItem);
            //}
            public MathPage()
        {
            InitializeComponent();
            String welcomeString = (String)PhoneApplicationService.Current.State["enterNameBox"];
            RadioButton easyMode = (RadioButton)PhoneApplicationService.Current.State["easyMode"];
            RadioButton hardMode = (RadioButton)PhoneApplicationService.Current.State["hardMode"];
            welcomeLabel.Text = "Welcome " + welcomeString;
           if (easyMode.Checked = true) { 
            
            }
        }
    
            private void getStartedButton_Click(object sender, RoutedEventArgs e)
            {
                MathTime();
                NavigationService.Navigate(new Uri("/Page1.xaml?enterNameBox=test", UriKind.Relative));
            }
        }
    
       
        }




Second Page


         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 FinalProjectPhoneVersion
    {
        public partial class MathPage : PhoneApplicationPage
        {
            public MathPage()
            {
                InitializeComponent();
                welcomeLabel.Text = "Welcome " + enterNameBox.Text;
            }
    
            private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
            {
    
            }
            protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
            {
                base.OnNavigatedTo(e);
                string parameterValue = NavigationContext.QueryString["enterNameBox"];
            }
        }
    }



Is This A Good Question/Topic? 0
  • +

Replies To: RadioButton.Checked not working

#2 plh  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 13
  • Joined: 23-May 11

Re: RadioButton.Checked not working

Posted 31 July 2014 - 11:20 PM

Where is the MathTime method?

and what is this doing in the MainPage class?

  
            public MathPage()
        {
            InitializeComponent();
            String welcomeString = (String)PhoneApplicationService.Current.State["enterNameBox"];
            RadioButton easyMode = (RadioButton)PhoneApplicationService.Current.State["easyMode"];
            RadioButton hardMode = (RadioButton)PhoneApplicationService.Current.State["hardMode"];
            welcomeLabel.Text = "Welcome " + welcomeString;
           if (easyMode.Checked = true) { 
            
            }
        }
              


Was This Post Helpful? 0
  • +
  • -

#3 Lottex  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-August 14

Re: RadioButton.Checked not working

Posted 05 August 2014 - 05:47 AM

Try
 if (easyMode.Checked == true) 
{

}



Was This Post Helpful? 0
  • +
  • -

#4 MagnusOS  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-August 14

Re: RadioButton.Checked not working

Posted 24 August 2014 - 03:28 AM

In C# there are different types of equal signs. For example:
!= (doesn't equal something)
== (matches up with something)
= (set the value of something)


Was This Post Helpful? 0
  • +
  • -

#5 Sylvane  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 16-July 14

Re: RadioButton.Checked not working

Posted 24 August 2014 - 03:42 AM

You're saying the code you're referring is in the MathTime() function but the function is not there, and I see you're calling the very same function under this button.

60	          private void getStartedButton_Click(object sender, RoutedEventArgs e)
61	        {
62	            MathTime();
63	            NavigationService.Navigate(new Uri("/Page1.xaml?enterNameBox=test", UriKind.Relative));
64	        }



Moreover, I'd like to know what exactly do you want to achieve if easyMode.Checked is true?.And why did you out this under the constructor.

55	       if (easyMode.Checked = true) {
56	         
57	        }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1