Hi,
I have added a button in the GroupByRecordPresenter (which is the header of a group.).
I want to actually know how to get all the collection of items that are grouped together.
I am sorry to mention here that the help has been very slow for me. I was posted couple of other questions for which I haven't got any response. Will be grateful for timely response.
Thanks,
Imad.
Hello Imad,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Please don't review the above post> i figured out the problem. It was the way things were handled in my code.
Thanks.
I putting the Buttons in the LabelContentStyle.
<Style x:Key="LabelContentStyle" TargetType="{x:Type ContentControl}">
<Setter Property="Padding" Value="10,3,10,3"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContentControl}">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ContentPresenter Margin="{TemplateBinding Padding}"
Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" HorizontalAlignment="Left"/>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="1">
<StackPanel.CommandBindings>
<CommandBinding Command="local:Viewer.GroupAckButtonPressed" CanExecute="GroupAckButtonPressed_CanExecute" Executed="GroupAckButtonPressed_Executed" />
<CommandBinding Command="local:Viewer.GroupClearButtonPressed" CanExecute="GroupClearButtonPressed_CanExecute" Executed="GroupClearButtonPressed_Executed" />
</StackPanel.CommandBindings>
<Button Content="Acknowledge" Margin ="0,0,3,0" Command="local:Viewer.GroupAckButtonPressed" CommandParameter="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:GroupByRecordPresenter}}}"/>
<Button Content="Clear" Command="local:Viewer.GroupClearButtonPressed" CommandParameter="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:GroupByRecordPresenter}}}"/>
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And that is how I have declared XamDataGrids in my XAML.
<igDP:XamDataGrid x:Name="Dg" AutoFit="True" HorizontalAlignment="Stretch" Grid.Row="1" HorizontalContentAlignment="Stretch" FieldLayoutInitialized="Dg_FieldLayoutInitialized" GroupByAreaLocation="AboveDataArea" SelectedItemsChanging="Dg_SelectedItemsChanging" PreviewMouseRightButtonDown="Dg_PreviewMouseRightButtonDown">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AllowAddNew="False" AllowDelete="False" AutoGenerateFields="True" FilterUIType="Default" SelectionTypeRecord="Extended" AllowFieldMoving="No" SelectionTypeField="None" SelectionTypeCell="None" />
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowRecordFiltering="True" CellClickAction="SelectRecord" FilterOperandUIType="None" />
</igDP:XamDataGrid.FieldSettings>
</igDP:XamDataGrid>
<
igDP:XamDataGrid x:Name="Dg_Clear" AutoFit="True" HorizontalAlignment="Stretch" Grid.Row="1" HorizontalContentAlignment="Stretch" FieldLayoutInitialized="Dg_FieldLayoutInitialized" GroupByAreaLocation="None" SelectedItemsChanging="Dg_SelectedItemsChanging" PreviewMouseRightButtonDown="Dg_PreviewMouseRightButtonDown">
</
igDP:XamDataGrid>
DataSource of both the XamDataGrids is same. Please let me know if you can figure out anything wrong that I am going here.
Thanks alot,
igDP:XamDataGrid x:Name="Dg_ACK" AutoFit="True" HorizontalAlignment="Stretch" Grid.Row="1" HorizontalContentAlignment="Stretch"
FieldLayoutInitialized="EventViewDg_FieldLayoutInitialized"
GroupByAreaLocation="None"
SelectedItemsChanging="EventViewDg_SelectedItemsChanging"
PreviewMouseRightButtonDown
="EventViewDg_PreviewMouseRightButtonDown"
Tag="{x:Static EventManagement:EventHandledState
.Acknowleged}">
<igDP:XamDataGrid.Resources
>
<local:GenerateEventPriorityColorConverter x:Key
="ValueToBrushConverter"/>
<Style
x:Key="CauseRowPlainPriorityStyle"
TargetType="{x:Type igDP:CellValuePresenter
}">
<Setter Property
="Template">
<Setter.Value
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment
="Stretch">
<Ellipse Height="15" Width="15" Margin="2,0,3,0" VerticalAlignment="Center" Stroke
="LightGray"
Fill="{Binding Path=DataItem.Priority, Converter={StaticResource ValueToBrushConverter
}}"/>
<TextBlock VerticalAlignment
="Center"
MaxHeight="24" MaxWidth="150" MinWidth="50" Margin="1,1,1,1" Width
="Auto"
Height="Auto" Text="{Binding Path=DataItem.Priority, Converter={StaticResource ValueToBrushConverter
</StackPanel
</ControlTemplate
</Setter.Value
</Setter
</Style
x:Key="CauseRowButtonStyle"
<Button Content="{DynamicResource Clear}" Command="local:Viewer.ClearButtonPressed" CommandParameter="{Binding Path=DataItem}" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" MaxHeight="24" MaxWidth="150" MinWidth="50" Margin="1,1,1,1" Width
Height="Auto" AutomationProperties.AutomationId="{Binding Path
=DataItem.ObjectID}"/>
</igDP:XamDataGrid.Resources
<igDP:XamDataGrid.CommandBindings
<!-- Listen for our custom ShowInChartCommand command. -->
<CommandBinding Command="local:Viewer.ClearButtonPressed" CanExecute="ClearButtonPressedCommand_CanExecute" Executed
="ClearButtonPressedCommand_Executed" />
</igDP:XamDataGrid.CommandBindings
<igDP:XamDataGrid.FieldLayoutSettings
<igDP:FieldLayoutSettings AllowAddNew="False" AllowDelete="False" AutoGenerateFields="True" FilterUIType="Default"
SelectionTypeRecord="Extended" AllowFieldMoving="No" SelectionTypeField="None" SelectionTypeCell
="None" />
</igDP:XamDataGrid.FieldLayoutSettings
<igDP:XamDataGrid.FieldSettings
<igDP:FieldSettings AllowRecordFiltering="True" CellClickAction="SelectRecord" FilterOperandUIType
</igDP:XamDataGrid.FieldSettings
</igDP:XamDataGrid
Thanks Stefan for your prompt reply.
In fact I was doing same thing but for some reason I am getting more records than what is there in the GroupByRecordPresenter.
I have two XamDataGrids on the same UserControl. I have added the Style in UserControl's resources so that it applies to both XamDataGrids. Now I have one GroupByRecord each in both XamDataGrids. One has for example 1 record and the other has 2 records but in ChildRecords collection of both XamDataGrid I am getting 3 records instead of 1 record.
I am not sure what wrong I am doing. Would you have any idea? Otherwise i then post my code.
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I copied the default Style for the GroupByRecordPresenter and add a Button in its Template. After that I handled the Button’s Click event and you can see the code I used for retrieving the ChildCollection of the current GroupByRecord. I copied the default Style from here: C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml file. Please let me know if this helps you or you need further clarifications on this matter.
Looking forward for your reply.