Hi,
We are evaluating 15.1. The CellBinding feature is a feature that we would really like to use, but I am running into an interesting issue. I have the following code. In the UI, the disabled cells show up gray and the enabled cells show up white, as expected. However, I'm still able to edit and change the value of the disabled cells. Is this a known issue, or am I doing something wrong?
<igdp:CurrencyField Name="Salary">
<igdp:CurrencyField.CellBindings>
<igdp:CellBinding Property="IsEnabled" Target="Editor" Binding="{Binding Path=DataItem.CanEditSalary}"/>
</igdp:CurrencyField.CellBindings>
</igdp:CurrencyField>
I'm pretty sure the binding is setup correctly, because as I noted, I do see the disabled cells being grayed out.
If I change the code as follows, all cells show up gray, as expected. However, this time I am not able to edit the cells, which is the behavior I would expect to see.
<igdp:CurrencyField Name="Salary" IsEnabled="False" />
I can attach a sample project that shows this issue if need be.
Hello Tory,
I have put together a sample project trying to reproduce the behavior with version 15.1 using your code snippet and it seems that on my side the cells are not editable when the CanEditSalary is false. Would you please have a look at the project and let me know if I am missing something in your scenario? Please also note that CellBinding equals setting a CellValuePresenter’s property locally. This means that the triggers in the default style where IsEnables property is used will not be applied.
Hi Maria,
Thanks for helping us with this issue. I did a little more research, and have narrowed in on the issue. We have defined the following style, since we have a special way that we want cell errors to be displayed. If I remove this style, the issue does not reproduce.
Do you see anything I'm doing wrong? Is there a different way to change how cell errors get displayed without interfering with the functionality of the CellBindings feature?
<DataTemplate x:Key="{x:Static igdp:DataPresenterBase.DataErrorContentTemplateKey}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Border x:Name="errorBorder" BorderThickness="1" BorderBrush="DarkRed" Visibility="Collapsed" SnapsToDevicePixels="True"> <Border BorderThickness="1" BorderBrush="#FFFF9696" Background="#FFFFEBEB" SnapsToDevicePixels="True" /> </Border> <ContentPresenter x:Name="content" ContentTemplate="{x:Null}" Margin="0,0,2,0" /> </Grid> <DataTemplate.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Host.HasDataError}" Value="true" /> </MultiDataTrigger.Conditions> <Setter TargetName="errorBorder" Property="Visibility" Value="Visible" /> </MultiDataTrigger> </DataTemplate.Triggers> </DataTemplate>
Hi Tory,
You are welcome. If you have any other questions, please feel free to update the thread.
You can consider this issue closed. We have decided not to pursue using CellBinding to the IsEnabled property, as it caused a number of UI display related issues (for example, not being able to control the disabled foreground/background colors of the cell) that we were not able to workaround.
However, I did make the change you suggested to the ContentPresenter in our DataErrorContentTemplateKey style, so that we are in-sync with the latest changes.
Many thanks for your help!
I am just checking if you had a chance to look into this and if you would like any further assistance on the matter.
I have spent more time on this and on the DataErrorContentTemplateKey template that you have mentioned. I have noticed that the DataContext binding is missing for the ContentPresenter as well as the ContentTemplate binding which is set to null. This seems to be the approach a while ago and since then a couple of changes were applied and the ContentPresenter definition looks like this: <ContentPresenter x:Name="content" ContentTemplate="{Binding Path=Content.Host.ContentTemplate, RelativeSource={x:Static RelativeSource.Self}}" DataContext="{Binding Path=Content.Host.DataContext, RelativeSource={x:Static RelativeSource.Self}}" Margin="0,0,2,0" />In the current context you need to set only the DataContext property so you can bind to DataItem’s property without any error thrown in the Output window. I would also suggest you to keep the ContentTemplate binding as it will allows any ContentTemplate that a custom CellValuePresenter style is setting to be used.Feel free to let me know if I could assist you further on this.
I've attached a sample app. You may need to update the references to point to the 15.1 Infragistics DLL. When you run the app, pay special attention to the Salary, EmpName, Age, and *** columns for the 2nd and 4th rows. Those cells are marked as non-editable, but the app lets you edit them anyway. Note you will need to double clicking to enter edit mode, since we have CellClickAction set to SelectCell.