带有Checkbox的ComboBox在WPF中的RadGridview

时间:2018-06-02 18:18:55

标签: wpf

我正在尝试在Radgridview中使用checbox实现组合框。但是,当我检查gridview单元格内的任何复选框项时,它会更改所有gridview单元格复选框选择。

期望是当我在gridviewcell中选择任何复选框时,它应该只更改所选的gridview单元格而不是所有gridviewcell复选框

请帮我解决这个问题。

以下链接显示了我期待的图像 combobox with checkbox within a WPF DataGrid

When i checked the checkbox selection in first row of the gridview The same selection is reflecting in second row of the gridview

<telerik:RadGridView Grid.Row="0" 
                             Name="pilotsGrid" 
                             ItemsSource="{Binding Pilots}"
                             AutoGenerateColumns="False" LoadingRowDetails="pilotsGrid_LoadingRowDetails" Loaded="pilotsGrid_Loaded"
                             Margin="5" CellEditEnded="pilotsGrid_CellEditEnded" CurrentCellChanged="pilotsGrid_CurrentCellChanged"
SelectionChanged="pilotsGrid_SelectionChanged">

         <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Country" Width="100" Name="grdColumn"  >
               <telerik:GridViewDataColumn.CellTemplate>
                  <DataTemplate>
                     <ComboBox TextBoxBase.TextChanged="ddlCountry_TextChanged" Name="ddlCountry" IsEditable="True" IsTextSearchEnabled="True"
                  StaysOpenOnEdit="True" SelectionChanged="ddlCountry_SelectionChanged" 
                  ItemsSource="{Binding DataContext.objCountryList,RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}" >
                        <ComboBox.ItemTemplate>
                           <DataTemplate >
                              <StackPanel>
                                 <CheckBox Name="chkCountry" Unchecked="AllCheckbocx_CheckedAndUnchecked" Checked="AllCheckbocx_CheckedAndUnchecked" Content="{Binding Country_Name}"  
                              IsChecked="{Binding Check_Status ,Mode=TwoWay}"  CommandParameter="{Binding Country_ID}" ></CheckBox>                                
                              </StackPanel>
                           </DataTemplate>
                        </ComboBox.ItemTemplate>
                     </ComboBox>
                  </DataTemplate>
               </telerik:GridViewDataColumn.CellTemplate>
            </telerik:GridViewDataColumn>
         </telerik:RadGridView.Columns>
</telerik:RadGridView>

0 个答案:

没有答案