locked
'System.Windows.Controls.RadioButton' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type

    Question

  • Good day

    I am trying to add a list of question and answers to my xaml by using a string form code behind (xaml.cs), the textblock is working fine but when i try to implement for the radio buttons i keep getting these errors

    "Error    1    'System.Windows.Controls.RadioButton' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type
    'System.Windows.Controls.RadioButton' could be found (are you missing a using directive or an assembly reference?)   "

    xaml

    ...........

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <TextBlock x:Name="lblQuestion" Height="50" TextWrapping="Wrap" Margin="0,10,0,547"/>
                <RadioButton x:Name="radA" Margin="0,65,0,492"/>
        
                <Button Content="Satrt" HorizontalAlignment="Left" Margin="174,488,0,0" VerticalAlignment="Top" Click="Button_Click"/>

            </Grid>

    xaml.cs

    .................

                                

    int score = 0;
                int i = -1;
                int a = 0;

                string[] questions = new string[]
        {
                        "1. Which Use of English Question Paper Type is given to you?",
                        "2.  According to the writer, the exciting thing about Spaceship Earth is that it ",
                        "3. The absence of instruction manual in Spaceship Earth has ",
                        " 4. From the passage, it can be deduced that man ",
                        "5. The writer's mood in the passage is that of ",
        };

            string[] answers = new string[] {
                     "A TypeA ", "B. Type B ", "C. Type C ", "D. Type D ",
                     "A has no instruction manual ", "B. is not difficult to maintain ", "C. is peculiar to other automobiles ", "D. is relatively easy to operate ",
                     "A made the operation of the Spaceship Earth difficult. ", "B. forced man to devise other means of travelling in Spacecraft", "C. challenged man's inquisitiveness", "D. made man helpless.",
                     "A learns by experiment and deduction ","B. learns by chance and accidentally ","C. is incapable of solving all his problems ","D. by his nature is in constant search of knowlege ",
                    "A non - commital ", "B. pessimism ", "C. optimism ", "D. frOstration ",

        };

            string[] quizAnswers = new string[] { "A TypeA", "A has no instruction manual", "C. challenged man's inquisitiveness", "A learns by experiment and deduction", "C. optimism ", };

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                if (i < questions.Length)
                    i++;
                //txtScore.Text = score;

                lblQuestion.Text = questions[i];

    radA.Text = answers[a];
        a++;
        radB.Text = answers[a];
        a++;
        radC.Text = answers[a];
        a++;
        radD.Text = answers[a];
        a++;
                



            }

    Regards and reply soon


    Jayjay john

    Sunday, October 19, 2014 8:44 PM

Answers

  • A RadioButtton doesn't have any Text property but it has a Content property that you can set:

    radA.Content = answers[a];
        a++;
    ...
    
    Please remember to mark helpful posts as answer and/or helpful.
    • Marked as answer by Joakins Sunday, October 19, 2014 9:46 PM
    Sunday, October 19, 2014 9:12 PM

All replies

  • A RadioButtton doesn't have any Text property but it has a Content property that you can set:

    radA.Content = answers[a];
        a++;
    ...
    
    Please remember to mark helpful posts as answer and/or helpful.
    • Marked as answer by Joakins Sunday, October 19, 2014 9:46 PM
    Sunday, October 19, 2014 9:12 PM
  • What type of app are you writing? System.Windows is not used in Windows Store apps.
    Sunday, October 19, 2014 10:33 PM
    Owner