0

simple question but i have not found the answer yet :S, i have currently 5 radiobuttons linked with an Image. i want to get the Name of the selected Radio button in my viewmodel. i have currently this XAML:

<StackPanel>
        <RadioButton Name="r1">
            <StackPanel>
                <Image Source="c:\image.png" ></Image>
            </StackPanel>
        </RadioButton>
        <RadioButton Name="r2">
            <StackPanel >
                <Image Source="c:\image.png"></Image>
            </StackPanel>
        </RadioButton>
        <RadioButton Name="r3">
            <StackPanel >
                <Image Source="c:\image.png"></Image>
            </StackPanel>
        </RadioButton>
        <RadioButton Name="r4">
            <StackPanel >
                <Image Source="c:\image.png"></Image>
            </StackPanel>
        </RadioButton>
        <RadioButton Name="r5">
            <StackPanel >
                <Image Source="c:\image.png" ></Image>
            </StackPanel>
        </RadioButton>
    </StackPanel>

how can i get the Name of the selected RadioButton in my ViewModel? thanks in advance:))

  • if you have a view model, please show its code and code where it is connected with view – ASh Jun 19 '18 at 10:00
  • i think your looking at this backwards, you want to bind the selected radio button to your view model, which is easily done with a value converter – MikeT Jun 19 '18 at 10:01
  • Are u using MVVM design pattern? If yes, Check this => https://www.wpftutorial.net/RadioButton.html ,Or Check this=> https://www.dotnetperls.com/radiobutton-wpf – lwin Jun 19 '18 at 10:03
  • thanks guys, ill check it out - will accept the duplicate – nairda-newb Jun 19 '18 at 10:05

0 Answers0