2011-12-16 65 views
0

可能有人請與下面的項目asssit控制,因爲我需要我的單選按鈕是水平不垂直單選按鈕控件中顯示

<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> 

回答

0

需要對項目控制中添加以下:

<ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
     <StackPanel Orientation="Horizontal"/> 
     </ItemsPanelTemplate> 
</ItemsControl.ItemsPanel> 
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> 

修改這個代碼,以滿足您的要求。希望它可以幫助你!

+0

試過,但佈局仍然是相同的 – Bruie 2011-12-16 15:59:35