Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1715
XamCheckEditor issues
posted

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 

Parents Reply
  • 9694
    Verified Answer
    posted in reply to Andrija

    After spending time with this, it appears bool fields using xamCheckEditors only send change notifications after the checkEditor loses focus. Since there appears to be no way to override this behavior, I would consider this a defect. If you would send a report in, that would be great!

    Online Form: http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx 

    In the meanwhile, I was able to get your original code (the simpler version without any of the INotificationChanged code) to work. I am posting the code to show how I use FieldSettings to specify the layout of the fields including using a regular checkbox for the two bool fields.

    Here is your original code-behind, untouched:

    public Window1()
    {
        InitializeComponent();

       
    IList<DataObject> l = new List<DataObject>();
       
       
    DataObject dataObj;
        dataObj =
    new DataObject();
        dataObj.Id =
    Guid.NewGuid().ToString();
        dataObj.Rollback =
    true;
        dataObj.Accept =
    false;
        l.Add(dataObj);

        dataObj =
    new DataObject();
        dataObj.Id =
    Guid.NewGuid().ToString();
        dataObj.Rollback =
    true;
        dataObj.Accept =
    true;
        l.Add(dataObj);

        dataObj =
    new DataObject();
        dataObj.Id =
    Guid.NewGuid().ToString();
        dataObj.Rollback =
    false;
        dataObj.Accept =
    false;
        l.Add(dataObj);

        myGrid.DataSource = l;
    }

    <Window x:Class="WindowsApplication2.Window1"
    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="WindowsApplication2">

    <Grid>
       
    <igDP:XamDataGrid Name="myGrid">

            <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" >
                                      
    <igDP:Field.Settings>
                                           <
    igDP:FieldSettings CellMinWidth="50" CellWidth="50"
                                                     
    CellValuePresenterStyle="{StaticResource BoolFieldOverride}"/>
                                       
    </igDP:Field.Settings>
                                   
    </igDP:Field>

                                   <igDP:Field Name="Accept" Label="Option Accept" >
                                      
    <igDP:Field.Settings>
                                          
    <igDP:FieldSettings CellMinWidth="50" CellWidth="50"
                                                       
    CellValuePresenterStyle="{StaticResource BoolFieldOverride}"/>
                                      
    </igDP:Field.Settings>
                                   
    </igDP:Field>

                     </igDP:FieldLayout.Fields>
                 
    </igDP:FieldLayout>
             
    </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>
    </Grid>
    </
    Window>

    This works with your code-behind. Please let me know if I can help further.

    Thanks,

Children