I have hierarchical xamDataGrid (3 layers) in which I place a +/- button in the HeaderPrefixArea which we would like to expand and collapse upon the +/- button click. Looked at the post (http://forums.infragistics.com/forums/p/37606/218282.aspx) and learnt that there is known issue here. Want to know if that is fixed in release 2010.2. If not, is there any work around for that? I tried the workaround solution given in the above posting but it is not working as desired.
Below is the code:
<Style TargetType="{x:Type igDP:HeaderPrefixArea}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:HeaderPrefixArea}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Stretch">
<Button Content="+" HorizontalAlignment="Left"
vm:RecordsExpandAllExtension.IsExpandedAll="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.IsExpandAllClicked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.ExpandAllCommand}"
Width="15"/>
<Button Content="-" HorizontalAlignment="Left"
vm:RecordsExpandAllExtension.IsCollapsedAll="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.IsCollapseAllClicked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.CollapseAllCommand}"
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
private bool _isExpandAllClicked = false;
public bool IsExpandAllClicked
{
get { return _isExpandAllClicked; }
set
if (_isExpandAllClicked != value)
_isExpandAllClicked = value;
this.RaisePropertyChanged("IsExpandAllClicked");
}
private bool _isCollapseAllClicked = false;
public bool IsCollapseAllClicked
get { return _isCollapseAllClicked; }
if (_isCollapseAllClicked != value)
_isCollapseAllClicked = value;
this.RaisePropertyChanged("IsCollapseAllClicked");
protected void XdgOnInitializeRecord(InitializeRecordEventArgs e)
if (IsExpandAllClicked)
e.Record.IsExpanded = true;
else
e.Record.IsExpanded = false;
public class RecordsExpandAllExtension
public static bool GetIsExpandedAll(UIElement obj)
using (Tracing.Source.FunctionScope())
return ExceptionHandling.Policy.Process(() =>
return (bool)obj.GetValue(IsExpandedAllProperty);
});
public static void SetIsExpandedAll(UIElement obj, bool value)
ExceptionHandling.Policy.Process(() =>
obj.SetValue(IsExpandedAllProperty, value);
public static bool GetIsCollapsedAll(UIElement obj)
return (bool)obj.GetValue(IsCollapsedAllProperty);
public static void SetIsCollapsedAll(UIElement obj, bool value)
obj.SetValue(IsCollapsedAllProperty, value);
public static readonly DependencyProperty IsExpandedAllProperty =
DependencyProperty.RegisterAttached(
"IsExpandedAll",
typeof(bool),
typeof(RecordsExpandAllExtension),
new UIPropertyMetadata(false, OnIsExpandedChanged));
public static readonly DependencyProperty IsCollapsedAllProperty =
"IsCollapsedAll",
new UIPropertyMetadata(false, OnIsCollapsedChanged));
public static void OnIsExpandedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
if (e.NewValue is bool)
if ((bool)e.NewValue)
XamDataGrid grid = Utilities.GetAncestorFromType(depObj, typeof(XamDataGrid), true) as XamDataGrid;
if (grid != null)
foreach (DataRecord dr in grid.Records)
if (dr.IsExpanded == false)
dr.IsExpanded = true;
public static void OnIsCollapsedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
if (dr.IsExpanded == true)
dr.IsExpanded = false;
on the last level, you won't see an indent because there are no child records and therefore no column for the expander. you can "fake it" by adding a margin to the presenter:
<igDP:FieldLayout.Settings>
<igDP:FieldLayoutSettings RecordSelectorLocation="LeftOfCellArea">
<igDP:FieldLayoutSettings.DataRecordPresenterStyle>
<Style TargetType="igDP:DataRecordPresenter">
<Setter Property="Margin" Value="20,0,0,0" />
</igDP:FieldLayoutSettings.DataRecordPresenterStyle>
</igDP:FieldLayoutSettings>
</igDP:FieldLayout.Settings>
Hi,
Thanks for the help, it works. But I have a question regarding the indentation in the XamDataGrid in the Sample. I am not able to get the indentation in my Grid for last level only (previous two levels are properly indented. Can you please let me know where I am doing wrong ?
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout IsDefault="True" Key="AccountTypeVM">
<igDP:FieldLayout.Fields>
<igDP:Field Label="Acct Type" Name="Name" Width="Auto">
</igDP:Field>
<igDP:Field Label="Acct Type Description" Name ="Description" Width="Auto">
<igDP:UnboundField Name="AccountTypeCategory" BindingPath="AccountTypeCategory" BindingMode="TwoWay" Width="Auto">
</igDP:UnboundField>
<igDP:Field Name="AccountClass" Width="Auto"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
<igDP:FieldLayout IsDefault="True" Key="AccountClassificationVM">
<igDP:Field Name="Abbreviation" Label="Class" Width="Auto" IsScrollTipField="True">
<igDP:Field Name="Description" Label="Class Description" Width="Auto">
<igDP:Field Name="AccountSubClass" Width="Auto"/>
<igDP:FieldLayout IsDefault="True" Key="AccountSubClassVM">
<igDP:Field Name="Abbreviation" Label="Sub-class" Width="Auto" IsScrollTipField="True">
<igDP:Field Name="Description" Label="Sub-class Description" Width="Auto">
</igDP:XamDataGrid.FieldLayouts>
Hello,
I have been looking into this and have found a way for you to easily achieve your goal using the RecordCollectionBase class’ exposed methods ExpandAll/CollapseAll. I have created a sample project (Grid_CollapseExpandAll.zip) showing them in action.
Please let me know if I can assist you any further on the matter.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
I have been looking into this issue and the referenced forum thread and was wondering if you could please elaborate on what exactly is wrong with the result you get form this code. It would also be very helpful if you could provide me a sample that uses it so that we are sure we are on the same page.
Looking forward to hearing from you.