I have two columns in my data source that is editable and is a boolean value. My data object implement INotifyPropertyChanged. Two questions:
1. When I initially run the app, all checkboxes are kinda grayed out, in some intermediate state, even though my data objects certain have values fro those boolean properties. How can I make sure they properly load?
2. The value of one bool depends on the other. The two properties cannot be true, but any other combination is possible. To this end, my data object has logic so if: valA is set to true, if valB is true, property valB is set to false and vice-versa. The issue is that the actual setter is not called by the Check Editor until the checkbox is unfocused. What's my best way to go around this? Should I attach custom event handlers to valuechanged? Should I create an unbound column and create a control template that displays my own custom checkbox with custom handlers?
Thanks,
-Szymon
I implemented this approach, because I did not see an alternative as of yet. The approach works great, with one exception.
I am defining my grids FieldSettings as follows:
<igDP:FieldSettings AllowEdit="True"
CellClickAction="EnterEditModeIfAllowed"
AllowGroupBy="False"/>
</igDP:XamDataGrid.FieldSettings>
I expected that when I entered the cell, either via Tab, or mouse click, that I enter the edit mode, however this does not happen when applying this style, and the user cannot edit the values of the checkbox with just the keyboard. Any way to force the cell to enter edit mode?
Thanks.
To address the above mentioned concerns, the fundamental problem with the XamCheckEditor is that the XamDataGrid paradigm of each cell supporting the concept of an edit mode toggle doesn't fit with the usual concept of working with a CheckBox. However, the XamCheckEditor supports this concept in order to implement a consistency with all cell editing. To get the expected behavior by using a standard WPF CheckBox, you would need to work around the focus issue as SameerKhanCiti mentions above. For more information how to work around that issue, check out Joe Modica's solution here.http://forums.infragistics.com/forums/p/5319/24600.aspx#24600
Another approach is to cause the checkbox to exit edit mode by checking that the XamDataGrid ActiveCell is not null and that the ActiveCell.IsInEditMode is true. When true, you can call the EndEditMode method on the ActiveCell. Do this before executing your save logic. Be careful about executing this code in an event though as there may be side-effects depending on the event.
Thank you,
Is there a fix for this yet?
The implementation that you have suggested has a flaw, if I tab into the cell with the checkbox, the cell has the focus and not the check box, so using the space bar to toggle between check/uncheck mode does not work.
Any idea how I might be able to solve the problem?
This sounds like a bug. Please report this issue to our developer support department (http://ko.infragistics.com/support/default.aspx) and ask them for a work-around. To get help immediately, we have chat and telephone support.
Thank you!
I implemented the xamdatagrid with checkboxes (placed in Cellvalue presenter) I added checked unchecked events for the check box. But i am facing one problem . On scroll of the xamdatagrid scroll bar level. I am seeing some of the check boxes are checked and unchecked. My application is behaving differntly. Can you please give some inputs on this.
I implemented the sample like this
<Window x:Class="Scrollbarissue_OnlyCheckBox.Window2"
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:sys="clr-namespace:System;assembly=mscorlib"
Title="Window2" Height="300" Width="300">
<Grid>
<igDP:XamDataGrid Name="myGrid" Height="250">
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="BoolFieldOverride">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:XamDataGrid.Resources>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False" />
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="Id" Label="GUID" >
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="250" CellWidth="250" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="Rollback" Label="Option Rollback" >
CellValuePresenterStyle="{StaticResource BoolFieldOverride}"/>
<igDP:Field Name="Accept" Label="Option Accept" >
<igDP:FieldSettings CellMinWidth="50" CellWidth="50"
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
{
/// <summary>
/// Interaction logic for Window2.xaml
/// </summary>
public partial class Window2 : Window
InitializeComponent();
DataObject dataObj;
dataObj.Id = Guid.NewGuid().ToString();
l.Add(dataObj);
}
dataObj = new DataObject();
dataObj.Rollback = false;
myGrid.DataSource = l;
public class DataObject
public bool Accept { get; set; }
In this sample i ddint added the events for check boxes. On scroll of the xamdatagrid scroll bar my check box checked and unched events are firing .