2012-10-31 48 views
1

我有一個ListView,它的項目是一組單選按鈕的,ListView的鍵合到100個字符串列表當我選擇一個單選按鈕,讓從第一項說,也許第二和第三,一切正常。但是,當我滾動了,也許50項或當我沒有出現在第一頁的任何項目中選擇一個單選按鈕,這是在以前的頁面中的第一項的選擇僅僅是取消,彷彿列表視圖再次呈現的項目,忘了五月操縱的Windows Store應用的ListView

 <ListView ItemsSource="{Binding}" x:Name="list" VirtualizingStackPanel.VirtualizationMode="Standard"> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation="Horizontal"> 
        <RadioButton Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x2" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x3" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x4" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x5" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x6" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 
        <RadioButton x:Name="x7" Template="{StaticResource CheckBoxTemplate2}" Foreground="Orange" Content="Test" Label="YOK" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Canvas.ZIndex="12" FontSize="14" FontWeight="Bold" FontFamily="Advantage-SemiBold" Checked="BetRadioButton_Checked_1" Click="x1_Click" /> 

       </StackPanel> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
    </ListView> 



list.DataContext = new List<String>() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", }; 

回答

0

我猜你的問題是,所有的RadioButton S的具有相同GroupName。單選按鈕的默認GroupName爲空,那麼所有的RadioButtons有相同GroupName。爲了解決這個問題,你需要想出一個獨特的GroupName爲每個項目在ListView。此外,您所有的Checked屬性都綁定到相同的屬性。你可能想要CheckBox而不是RadioButton

+0

LOL,感謝您的回答,但問題是,一點點推進。但無論如何感謝。 –

相關問題