项目控件中的单选按钮显示

时间:2011-12-16 14:38:40

标签: silverlight xaml

有人可以协助下面的项目控制,因为我需要我的单选按钮是水平而不是垂直

<ItemsControl Name="rbQuestionAnswer" ItemsSource="{Binding Answers, Mode=TwoWay}"    IsEnabled="{Binding IsEnabled, Mode=OneWay}"  >
    <ItemsControl.ItemTemplate >
        <DataTemplate >
            <RadioButton GroupName="{Binding SurveyLineID}"
                                 Content="{Binding Answer}" 
                                 Tag="{Binding AnswerId}"               
                                 Style="{StaticResource RadioButtonStyle}"
                                 IsChecked="{Binding IsSelected, Mode=OneWay}"            
                                 Checked="RadioButton_Checked"
                                 Visibility="{Binding Path=IsRadio,Converter={StaticResource BoolConverter}}" >
            </RadioButton>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

2 个答案:

答案 0 :(得分:1)

我认为您可以使用<StackPanel/>来执行此操作。请尝试以下代码。

<ItemsControl ItemsSource="{Binding Options}">
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <RadioButton GroupName="{Binding AnswerId}" Content="{Binding Option}" IsChecked="{Binding IsSelected, Mode=OneWay}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
</ItemsControl>

修改此代码以满足您的要求。希望,它可以帮助你!

答案 1 :(得分:0)

需要在Items控件中添加以下内容:

<ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal"/>
       </ItemsPanelTemplate>
 </ItemsControl.ItemsPanel>
相关问题