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.
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!
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!
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.
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.
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.