We have a data grid control which contains a check box. The problem is that in the infragistics version 9.1, we are not able to set the
value of the checkbox to checked.The code for both data grid with check box and setting the value of checkboxes as checked to true is as under:
----------------------------------------------------------------------------------------------------------------------------
Code to set the value of the checkbox in the grid to true (this throws an exception):
foreach (Record rec in dgLicenseInfo.xamDataGrid1.Records)
{
((DataRecord)rec).Cells[0].Value = true;
}
Code for datagrid with checkbox :
<UserControl x:Class="Risco.RSP.AC.ACOS.UI.UControl.DataGridWithCheckbox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:Cont="clr-namespace:Risco.RSP.AC.ACOS.UI.UControl"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Height="300" Width="300" >
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="CheckboxField">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Cont:CheckBoxControl Evt="GridCheckBoxChecked"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<igDP:XamDataGrid x:Name="xamDataGrid1" UpdateMode="OnCellChange" CellUpdated="dgdata_CellUpdated" Background="White"
BorderBrush="DarkGray" BorderThickness="1" Theme="Office2k7Blue" GroupByAreaLocation="None" AutoFit="True"
InitializeRecord="dgdata_InitializeRecord">
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False" CellClickAction="EnterEditModeIfAllowed" />
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings DataRecordSizingMode="SizedToContentAndFixed" RecordSelectorLocation="None"
HighlightAlternateRecords="True" AutoArrangeCells="LeftToRight" AllowAddNew="False" AllowDelete="False" SelectionTypeCell="Extended" >
</igDP:FieldLayoutSettings>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:UnboundField x:Name="CheckBoxcol" >
<igDP:UnboundField.Settings>
<igDP:FieldSettings
CellMaxWidth="17" LabelMaxWidth="17"
CellValuePresenterStyle="{StaticResource CheckboxField}" CellClickAction="SelectCell" AllowEdit="True" >
<igDP:FieldSettings.LabelPresenterStyle>
<Style TargetType="{x:Type igDP:LabelPresenter}">
<EventSetter Event="Loaded" Handler="OnNameLabelLoaded" />
</igDP:FieldSettings.LabelPresenterStyle>
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</Grid>
</UserControl>
I just found the answer I believe. I changed the check box and added "Mode=OneTime" and it works now. I had thought the Mode indicates how the checkbox was to reactive during the user session. Just getting my feet wet wtih WPF along with MVVM.
IsChecked
=PropertyChanged}"/>
I am having the same problem. Can you please clarify? If I add RelativeSource={RelativeSource TemplatedParent}, The user cannot uncheck the box. All I am trying to accomplish is to have the checkbox initialized with the bool value I have on my database table.
Thank you in advance.
Hello,
Have you tried setting the IsChecked property of the editor - in your case the Cont:CheckBoxControl element inside the CVP's control template?