Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Expand/Collapse button in Xamdatagrid header prefix area
posted

I added a button in Xamdatagrid headerprefix area.

<Style TargetType="{x:Type igDP:HeaderPrefixArea}">

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:HeaderPrefixArea}">
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="10" Height="10" Content="{Binding DataPresenter.DataContext.ExpandCollapse}"
Command="{Binding DataPresenter.DataContext.ExpandCollapseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=igDP:XamDataGrid}}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

and inside command i have written code to exapnd all records.

private void ExapndCollapse(object obj)
{
XamDataGrid grid = obj as XamDataGrid;
if (isExpand)
{
foreach (var record in grid.Records)
{
record.IsExpanded = true;
}

isExpand = false;
}
else
{
foreach (var record in grid.Records)
{
record.IsExpanded = false;
}

isExpand = true;
}
}

But now after expanding each row again i am getting this expand collapse button in sub header prefix areas. even when i click child header sections command is getting fired and all collapsed.

Can you please provide any suggestion.