Hi, I'm using XamDataGrid to display a bonds grouped by a bid list (see the image below). Sometimes I need to display bid lists that are empty (i.e. contain no bonds). To create an empty bid list grouping I insert a "special" fake bond into it. But in this case I want the grouping to show a special message spanning the columns (like the first groping in the image below). What is my best strategy to achieve something like this with XamDataGrid? Thanks!
Hello,
I was just wondering if that solution works on your end? Please let me know if you have questions on this matter.
There are couple of more ways to try with. If you cannot change the virtualization mode, then you can try with using only one style but changing only the ControlTemplate. For example - the DataRecordCellArea. Here is an example of what I have in mind :
<Style TargetType="{x:Type igDP:DataRecordCellArea}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataItem.Id}" Value="-1">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:DataRecordCellArea}">
<Grid>
<TextBlock Text="Drag Bids here..." FontSize="16" Margin="10,10,10,20" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
However, going with this, it would be hard to keep the TextBlock from not scrolling. You would have a better control over its position if you retemplate the CellValuePresenter element instead. You could create a dummy unbound field and put it "under" the pinned fields. Here is a sample style for the CellValuePresenter:
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Grid Background="Transparent">
<TextBlock Text="Drag Bids here..." FontSize="16" x:Name="tblock"
Visibility="{Binding Path=Field.Name, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource conv}}"/>
The converter is used to return Visible only if the Field.Name matches the name of the Dummy Unbound Field. Here is a screenshot of what I am getting and the full sample:
Alex, I have switched to the latest service release (from 1007) and and I don't see the problem with closing/opening the group any more. I do see the problem with scrolling that you mentioned though. Switching to "Virtualize" slows down my real grid very significantly, so I would prefer to stay with default RecordContainerGenerationMode.Is there a different workaround for the scrolling problem?Another problem that I noticed relates to the fact that I have several columns in my grid fixed. When I scroll horizontally the "special" template is also scrolled away. Is there a way to "fix/pin" it?
Thanks!
I tried this and I cannot reproduce it ( I switched from 10.1 to the latest service release for 9.2 - 9.2.20092.2094 )
However I noticed a behavior when you are scrolling fast, the template for the dummy item could apply to a non-dummy item because of the virtualization. This can be resolved by switching to a more aggressive virtualization strategy - like Virtualize :
xamDataGrid1.RecordContainerGenerationMode = Infragistics.Windows.Controls.ItemContainerGenerationMode.Virtualize;
Please tell us what build of our controls are you using and what environment are you testing this agains (mine is 9.2.20092.2094, Windows 7 Enterprise).
Hi Alex,
I changed you code to:public override Style SelectStyle(object item, DependencyObject container) { DataRecord dr = item as DataRecord; Bid dataItem;
dataItem = dr.DataItem as Bid; // a Bid with a negative Id is a dummy bid if (/*dr.ParentRecord is GroupByRecord && */ dataItem != null && dataItem.Id < 0) { return _grid.Resources["DRPDummyStyle"] as Style; }
return base.SelectStyle(item, container); }
and it made no difference. Just clicking on plus icon to close the group and then again to reopen restores the original template. Do you observe the same problem on you side?