Image RadioButton : RadioButton « Windows Presentation Foundation « C# / C Sharp






Image RadioButton

Image RadioButton
 
<Window x:Class="ControlDemos.RadioButton"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ControlDemos" Height="600" Width="500">
    <Grid>
      <StackPanel>
        <RadioButton Click="HandleSelection" Name="r1">
          <StackPanel Orientation="Horizontal">
            <Image Source="c:\image.jpg" ></Image>
            <TextBlock FontSize="24" Height="35" Width="150">A</TextBlock>
          </StackPanel>
        </RadioButton>
        <RadioButton Click="HandleSelection" Name="r2">
          <StackPanel Orientation="Horizontal">
            <Image Source="c:\image.jpg" ></Image>
            <TextBlock FontSize="24" Height="35" Width="150">B</TextBlock>
          </StackPanel>
        </RadioButton>
        <RadioButton Click="HandleSelection" Name="r3">
          <StackPanel Orientation="Horizontal">
            <Image Source="c:\image.jpg" Height="200" Width="256"></Image>
            <TextBlock FontSize="24" Height="35" Width="150">C</TextBlock>
          </StackPanel>
        </RadioButton>
      </StackPanel>
  <Menu Name="menu1" />
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ControlDemos
{
    public partial class RadioButton : Window
    {

        public RadioButton()
        {
            InitializeComponent();
        }
        public void HandleSelection(Object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.RadioButton b = (sender as System.Windows.Controls.RadioButton);
            StackPanel d = (StackPanel)b.Content;
            TextBlock t = (TextBlock)d.Children[1];
            Console.WriteLine(t.Text);
        }
    }
}

   
  








Related examples in the same category

1.Checked RadioButtonChecked RadioButton
2.Use StackPanel to Hold RadioButtonsUse StackPanel to Hold RadioButtons
3.Circled Radio ButtonsCircled Radio Buttons
4.Color animate based on Radio Button Click eventColor animate based on Radio Button Click event
5.Radio Button GroupsRadio Button Groups
6.Set RadioButton to check stateSet RadioButton to check state
7.RadioButton click eventRadioButton click event
8.Use RadioButton to control TextBox alignmentUse RadioButton to control TextBox alignment
9.RadioButton checked event handlerRadioButton checked event handler