Autor Beitrag
Greenberet
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 339
Erhaltene Danke: 20

Win 10
C# (VS 2012), C++ (VS 2012/GCC), PAWN(Notepad++), Java(NetBeans)
BeitragVerfasst: Mi 29.08.07 12:50 
Hi,
ich hab momentan in meiner Form 3 RadioButtons und ich hab ein DependencyProperty vom Typ int.
Ich würd jetzt gerne die 3 RadioButtons auf das DependencyProperty binden (TwoWay). So dass halt wenn der oberste selectiert wurde der wert 0 ist beim nächsten 1 usw..

Mein Problem ist, ich hab keine Ahnung wie ich ein solches Binding erstell^^
Ich hab schon nach ner art Value Property gesucht dass ich dem Radiobutton zuweisen kann, allerdings ohne Erfolg.

Die einzig andere Möglichkeit die mir eingefallen ist, wäre einen Converter zu schreiben.

Kennt wer von euch vl. eine andere Möglichkeit wie ich das machen kann? ( Nur XAML bevorzugt^^ )
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 29.08.07 14:17 
WPF kennt zwar keine RadioButtonGroup, sie lässt sich aber leicht nachbauen: werfe deine RadioButtons in eine ListBox (oder einen anderen Selector) und binde IsChecked der ersteren an IsSelected des jeweiligen ListBoxItems und schließlich SelectedIndex der ListBox an deine int-Property.
Greenberet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 339
Erhaltene Danke: 20

Win 10
C# (VS 2012), C++ (VS 2012/GCC), PAWN(Notepad++), Java(NetBeans)
BeitragVerfasst: Mi 29.08.07 22:17 
darauf hätt ich auch kommen können :autsch: :autsch:
vielen dank

*edit*
Das binding vom SelectedIndex auf mein int Property bekomm ich hin, nur irgendwie bekomm ich das Binding vom ListBoxItem.IsSelected auf RadioButton.IsChecked nicht hin.

Das Hier wäre meine ListBox
ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
<ListBox Grid.Column="3" Grid.Row="6" SelectedIndex="{Binding Backup}" Style="{StaticResource CXMControl}">
  <RadioButton GroupName="rbgrpBackUp" x:Name="rbAllways"  IsChecked="{Binding ListBoxItem.IsSelected}">
    <TextBlock Style="{StaticResource CXMCaption}" Text="Allways create backups"/>
  </RadioButton>
  <RadioButton GroupName="rbgrpBackUp" x:Name="rbAsk" IsChecked="{Binding ListBoxItem.IsSelected}">
    <TextBlock Style="{StaticResource CXMCaption}" Text="Ask everytime"/>
  </RadioButton>
  <RadioButton GroupName="rbgrpBackUp" x:Name="rbNever" IsChecked="{Binding ListBoxItem.IsSelected}">
    <TextBlock Style="{StaticResource CXMCaption}" Text="Never create backups"/>
  </RadioButton>
</ListBox>


*edit2*
ich hab das ganze jetzt über einen converter gelöst. aber trotzdem danke.