svyatko svyatko

Niner since 2011


  • Silverlight Input Controls - Day 2 - Part 12

    Hi Guys,

    I am having a pretty stupid problem, and i am breaking my head on why it doesnt work.

    Its a simple thing i am sure, but it doesnt fit in my head for some reason.


    I have 1 text block , 3 radio buttons and 1 button. all i want is to display current radio button selection/value in the textblock by pressing a button.  here is my code so far.

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <TextBlock Height="83" HorizontalAlignment="Left" Margin="26,69,0,0" Name="resultTextBlock" Text="TextBlock" VerticalAlignment="Top" Width="330" />
                <RadioButton Content="X" Height="72" HorizontalAlignment="Left" Margin="12,166,0,0" Name="ciaRadioButton" VerticalAlignment="Top" IsChecked="True" />
                <RadioButton Content="Y" Height="72" HorizontalAlignment="Left" Margin="12,244,0,0" Name="mi6RadioButton" VerticalAlignment="Top" IsChecked="False" />
                <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="249,457,0,0" Name="button1" VerticalAlignment="Top" Width="160" />
                <RadioButton Content="Z" Height="72" HorizontalAlignment="Left" Margin="9,322,0,0" Name="nsaRadioButton" VerticalAlignment="Top" IsChecked="False" />


    code language="csharp"] private void button1_Click(object sender, RoutedEventArgs e)
                string radioButtonValue;
                if (RadioButton1.IsChecked == true)
                    radioButtonValue = "valueX";
                    resultTextBlock.Text = radioButtonValue;
                else if (RadioButton2.IsChecked == true)
                    radioButtonValue = "valueY";
                    resultTextBlock.Text = radioButtonValue;
                    radioButtonValue = "valueZ";
                    resultTextBlock.Text = radioButtonValue;


    I have tried havimg Radio buttons in one group, in separate groups, but without luck.


    Is there anything obvious?? I might have been sitting infront of the pc for too long Smiley


    Any help would be appreciated.