I recently upgraded my XamDataGrid from the express version to the release version 9.2.20092.2001. After the upgrade, my custom ExpandableFieldRecordPresenter stopped working correctly. I went ahead and upgraded its basline XAML code from the newer DefaultStyles and have begin fixing the problems. One of them I can't seem to fix. In the old datagrid's ExpandableFieldRecordPresenter, I had the margin set so that two adjacent child tables (not rows but the entire tables) would be separated by a larger space (ex. <Setter Property="Margin" Value="0,20,0,20"/>). This approach doesn't have the same effect with the new ExpandableFieldRecordPresenter. Instead of adding space between the tables, it adds space between table headers (not column headers) and the rest of the data for any particular table. Obviously that is not the desired result. How do I control the spacing between tables now? For reference, here is a thread I started a while back that had the correct answer for the express edition:
http://forums.infragistics.com/forums/p/29045/143162.aspx#143162
Thank you.
P.S. I am using NetAdvantage for WPF 2009 Volume 2 with service release NetAdvantage_WPF_20092_SR_2001.msp.
There was a behavior change that was made in 9.2 that was designed to increase scrolling performance. By default we now use a single panel to lay out all the records. Before we had used nested panels for each level of the hierarchy. However, one advantage to the old nested panel approach is that it allowed more flexiblity in controlling the layout of the nested records. This is the reason that the margin property setting is no longer having the desired effect in your scenario.
We decided to default the behavior to the new single panel approach because we felt it offered the most benefit to the greatest number of users. However you can opt back into the nested panel approach by setting the UseNestedPanels property on ViewSettings. e.g.:
<igDP:XamDataGrid>
<igDP:XamDataGrid.ViewSettings>
<igDP:GridViewSettings UseNestedPanels="True"/>
</igDP:XamDataGrid.ViewSettings>
</igDP:XamDataGrid>
Thank you Joe. One of the reason I upgraded was to take advantage of bug fixes. If I use the nest panels option with the newer XamDataGrid, will any of the bug fixes be negated?
Hello,
There seems to be a way around this - using the new not nested panels. This time you would not target the ExpandableFieldRecordPresenter but the DataRecordPresenter and especially the HeaderRecord, which is always the first one of the field layout ( and below what used to be the nesting ExpandableFieldRecordPresenter)
So to make this work, you can create a style for the DataRecordPresenter and a Converter, like this:
<local:MyConverter1 x:Key="conv1"/>
...
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="Margin" Value="{Binding Converter={StaticResource conv1}}"/>
</Style>
What the Converter does is to see if the record is a HeaderRecord and not in the default layout (because you probably do not want a margin there):
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Record r = (Record)value;
if (r == null)
return Binding.DoNothing;
if (r.RecordType == RecordType.HeaderRecord && !r.FieldLayout.IsDefault)
return new Thickness(0, 20, 0, 0);
else return Binding.DoNothing;
}
I am attaching of screenshot with the effect you should get. That is what you are trying to achieve, right?
So, if you are willing to go with this approach (decide where to put spaces depending on the record's type) you have to find another way to distinguish where your table ends.
There is no straightforward way of doing this as all the different types of record are in the same panel, or at least I cannot find any.
What I was able to come up with is to use the AddNewRecord. You can set its location to OnBottom and this will be your bottom marker.
If you do not use it, you can set its Opacity, IsHitTestVisible or Visibility in order to hide it. Here is the modified DataRecordPresenter style:
<Style.Triggers>
<Trigger Property="IsAddRecord" Value="True">
<Setter Property="Margin" Value="0,20,0,0"/>
<Setter Property="Opacity" Value="0" />
<Setter Property="IsHitTestVisible" Value="false"/>
</Trigger>
</Style.Triggers>
On the screenshot should be the actual result.
Note that the bottom space is bigger that the top, because there is a record there, so you could reduce the margin on the AddNewRecord.
Hi Alex,
That's an interesting idea and the explicit example doesn't quite achieve what I want but the general approach might. Consider the following would be what I'm looking for:
- ALFKI Alfreds Futterkiste Maria Anders
.......+ CustomerCustomerDemos
< BIG SPACE HERE >
.......- Orders
..............10643 Alfki
..............10692 Alfki
..............10835 Alfki
..............10952 Alfki
..............11011 Alfki
+ ANATR Ana Trujillo Emparec Ana Trujillo
+ ANTON Antonio Moreno Tac Antonio Moreno
Let me know what you think.
Thanks!