나는 이것을 작동 시키는데 어려움을 겪고 있습니다. 이 코드는 MVVM 앱에 있으며 ViewModel의 속성에 라디오 버튼을 바인딩합니다. ListBox에있는 가로형 라디오 버튼
나는이 SO https://stackoverflow.com/a/2285732모든이 버튼이 수직으로 적층되는 것을 제외하고는 잘 작동 답변을 구현하기 위해 노력하고있어. 자, 이것은 쉬운 수정, 그냥 ItemsPanelTemplate 수정 보인다.
<ListBox ItemsSource="{Binding ItemOptions}" SelectedItem="{Binding SelectedOption}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" IsItemsHost="True" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}" >
<RadioButton Content="{TemplateBinding Content}"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
그러나, 항목이 수직으로 적층 된 상태로 유지 :
여기 내 코드입니다. 이것이 ListBox의 방향에 아무런 영향을 미치지 않는 이유는 무엇입니까? 내가 뭘 놓치고 있니?
감사합니다, 제리
XAML과 F5를 복사하여 붙여 넣기 만하면됩니다. 항목은 가로로 쌓입니다. 어떤 .Net 버전을 사용하고 있습니까? –
대상 지정 .NET 4.0 –
그렇다면 이해할 수 없습니다 ... 또한 4.0을 사용하고 있으며 정확한 XAML이 내 PC에서 잘 작동합니다 .... –