Hello,
I have attached a sample that displays a problem a full project I have been working on is exhibiting. I'm using an attached property behavior to set custom field layouts. It gets applied... but only to the second and subsequent items. It does not apply to the first item!
If I change "LabelLocation" to "InCell", all of them display the correct for that style, but this is not desired behavior for the full program (where there's about 20 fields with sub-layouts as well).
I'm also placing this grid inside a XamTabControl and getting an exception of "FieldLayout can not be moved to another DataPresenterBase." when it hits "target.FieldLayouts.Add( layout );" but I think I need instead to bind to FieldLayoutInitializing in there, so that is a problem I can investigate myself for now.
I look forward to any assistance you might be able to provide, thank you!
Hi,
I looked at the sample application that you provided, but I couldn’t find an issue. I don’t understand what exactly doesn’t apply on the first item and what do you mean by the first item – the first field, field layout, record or something else?
Thanks,
Diyan Dimitrov
In the sample the field layout isn't being applied to the first record; but it is being applied to all subsequent records. I hope that clears it up.
I should probably elaborate a little more; I apologize for the shortness of my last reply!
The field layouts are generated programmatically - this is due to some extreme complexity and variety in the data that gets displayed in a reusable datagrid user control. The fields are applied via the Attached Behavior pattern, which I decided to go with after finding another post elsewhere on the forums suggesting that. It seems to work; save two flaws. The one that I'm asking about here is that it appears as though the field layouts are not applied to the first item. (So grid record 1) But they ARE applied to grid records 2, 3, 4, and so on.
I can provide a screenshot if necessary; but when the sample is loaded into VS2010 SP1 designer for me it even displays on the grid preview page. Would you like me to attach a screenshot of the grid displaying the first record not having the field layout applied?
Yes, that would help me understand the issue.
Here is a screenshot of the behavior. This happens in both design mode and in runtime.
I am attaching a screenshot with the latest service relase for 11.1 build 11.1.20111.2053. What version and build are you using?
If that's from 2053, then I may need to upgrade. The current version of the tools we are using is 11.1.20111.1002.
The style that's not getting applied can't really get put above the DataSource in the xaml, because it's its own separate element, something like this:
<igDP:XamDataGrid ... ... ... DataSource="{Binding Path=MyPath}"><igDP:XamDataGrid.FieldSettings><igDP:FieldSettings ... ... ...CellValuePresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings></igDP:XamDataGrid.FieldSettings></igDP:XamDataGrid>
I don't think there's any way to move the DataSource after the FieldSettings, is there?
But I'd be surprised if it's beginning to render the data before it's even processed the xaml, but you're right that it does appear to be some kind of a timing issue. That's where I'm hoping something within Infragistics code might have fixed this.
As one quick other point, I can see in the debugger that the CellValuePresenterStyle is set properly on the grid, but not on any lower level FieldLayouts or individual Fields. So it's not that it's not being set, or that it's being overwritten. It's something in Infragistics' processing of that. But I can see, using Snoop, that the default Infragistics stylings - the individual colors, that is - are being used for the errant record.
Why are you not able to flip the order of variables in the XAML code? That's what worked for me in the end.
It looks like the rendering is a multi-threaded or multi-capable handling processor, because it starts rendering the datasource as soon as it gets it; having the formatting first gets the formatting rendering while the datasource hasn't been built. That minor delay is what seemed to be the problem.
Not a whole lot of help, but at least a bit of clarification.
Hi - we've stumbled into a similar problem with different enough circumstances that we cannot apply this suggested fix directly. But the bottom line is that we're facing the same symptoms: set a CellValuePresenter style for use by the entire grid, but it only has effect on rows 2-n. The first row is initially unstyled, but as you scroll around, a different random row will become unstyled instead, and so on.
So my question is: is the fix suggested more of a workaround to hide an existing Infragistics issue? Might the issue surface in other ways? And if so, might it be something that's been fixed in a later release?
I will probably need to open a separate issue on this, but was hoping for some guidance in the context of Collin's original issue.
That certainly does help and has managed to solve my wonderfully troublesome problem! I had been under the (apparently mistaken) impression that properties and in particular attached properties weren't necessarily processed in the order laid out in the xaml, but it seems I was wrong.
Again, thank you!
The simplest way to get the desired result is to set the DataSource after setting the attached property for the layouts.
<igDP:XamDataGrid x:Name="DataGrid" GridTesting:AddFieldLayoutBehavior.FieldLayouts="{Binding Path=FieldLayouts}" DataSource="{Binding Path=DataCollection}" Margin="0,0,0,-134">
<igDP:XamDataGrid x:Name="DataGrid"
GridTesting:AddFieldLayoutBehavior.FieldLayouts="{Binding Path=FieldLayouts}"
DataSource="{Binding Path=DataCollection}" Margin="0,0,0,-134">
Hope this helps!