I want to check the specific checkbox on xamdatagrid only. When i click on the specific row, only the checkbox on that row is checked. How can i achieve this?
======XAML======
<Grid.Resources> <Style x:Key="CheckboxStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <!--<CheckBox IsEnabled="True" Content="{Binding IsCheckedBoolean}" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}" Command="{Binding BooleanType}" CommandParameter="{Binding IsCheckedBoolean, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}" />--> <CheckBox IsChecked="{Binding DataContext.IsCheckedBoolean, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources>
<igDP:UnboundField Label="Action" Width="auto"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource CheckboxStyle}" /> </igDP:UnboundField.Settings> </igDP:UnboundField>
=======View Model======
public Boolean IsCheckedBoolean { get { return _isChecked; } set { _isChecked = value; RaisePropertyChanged("IsCheckedBoolean"); } }
Hello Donna,
Thank you for choosing Infragistics.
I have been looking into your issue and I believe I have come up with a solution that will help you achieve the functionality you are looking for. I have prepared a sample application for you to test and see if the desired effect is achieved.
In the XamDataGrid’s Resources I have defined a custom Style representing a CheckBox for the UnboundField in the grid. The IsChecked property of the CheckBox is bound to the IsSelected property of the DataRecord. In the XamDataGrid’s FieldSettings I have set the value of the CellClickAction property to SelectRecord. When the CellClickAction property is set to SelectRecord you have to double click the cell in order for it to go into edit mode. Whenever a cell is clicked, it’s corresponding Record will be selected.
If you need any further assistance on this matter, please do not hesitate to ask.
Thanks Tacho for your fast respond. However what I want to achieve is when user clicks on the checkbox, the checked row data will put into another XamDataGrid that shows on the same page. Then the checkbox on the first XamDatGrid will be disabled. Do you have any idea?
I have prepared a new sample application for you to test and see if the desired effect is achieved. The implementation is based on MVVM and it is using Commands instead of Events.
The ItemMvvM class in the ViewModel is used to provide the data from the Model in a form that the View can easily use. In this case we reform the implementation of the Item class. The RelayCommand class implements the ICommand interface and so enhancing its functionality.
The ViewModel class implementation contains the DataSources of the XamDataGrids and also the Commands with their corresponding methods which are used to achieve the functionality you desire.
If you require any further assistance on this matter, please do not hesitate to ask.
I am currently investigating your issue and will need some more time to finish my investigation. I would get back to you as soon as I am done with my research.
Thanks Tacho. This sample meet my requirements. However, I'm using MVVM pattern. I have a model class named Item. The XamDataGrid 1 is binding to the class Item via ViewModel. eg: Item xdg1 = new Item();
How can I implement the click function in ViewModel? Thanks again.
Thank you for your feedback.
I have been looking further into your issue and I have modified the sample from my previous post according to the behavior you have explained.
I have defined two XamDataGrids and both of them have a Style representing a CheckBox for the RecordSelector. I have handled the Click events of both of these CheckBoxes.
In the Click event of the CheckBox from the top XamDataGrid I am adding the DataItem of the RecordSelector's DataRecord to the DataSource of the bottom XamDataGrid if the Record's CheckBox is checked. The CheckBox is disabled afterwards.
In the Click event of the CheckBox from the bottom XamDataGrid I am iterating through the DataRecords of the top grid's DataSource. If the DataItem of a particular record matches the Person instance from our bottom XamDataGrid the Person instance from the bottom XamDataGrid is removed and the CheckBox for the corresponding Person Record in the top XamDataGrid is enabled.