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
110
How do i access to GroupBy value, Value on which my xamDataGrid is grouped?
posted

Here is the scenario

I have a xamDataGrid where i want the records shown in heirarchy. I want to add a button for clear all and select all on each group level. and on button click event i bind the button datacontext with DataPresenter.ActiveRecord, but on select all and clear all button click event i find the DataContext of a button == null.

here is the xaml, Grid is binded as follows,

 

Name="GrdUsers" Source="{Binding Source={StaticResource DsProvider}}"

With other visible colum there is an invisible column

 

 

 

 

 

<

 

igDP:UnboundField Name="UserRoleId" BindingPath="UserRoleId" Visibility="Collapsed">

 

 

 

 

<igDP:UnboundField.Settings><igDP:FieldSettings AllowEdit="False"/></igDP:UnboundField.Settings></igDP:UnboundField>

and in SortedFields

 

 

 

<

 

igDP:FieldSortDescription FieldName="UserRoleId" Direction="Ascending" IsGroupBy="True">

Here is a column on which Select all and clear all appears on the header for each group.

 

 

 

 

 

 

<

 

igDP:UnboundField loc:Resource.Uid="NameColumn" Label="{loc:Resource}">

 

 

 

 

<igDP:UnboundField.Settings><igDP:FieldSettings CellValuePresenterStyle="{StaticResource PersonNameStyle}" LabelPresenterStyle="{StaticResource PermitAllInGroupStyle}"/>

 

 

 

</igDP:UnboundField.Settings></igDP:UnboundField>

Here is the style of a header

 

 <Style x:Key="PermitAllInGroupStyle" BasedOn="{StaticResource {x:Type igDP:LabelPresenter}}"

 

 

TargetType="{x:Type igDP:LabelPresenter}"><Setter Property="Template"><Setter.Value>

 

 

 

<ControlTemplate TargetType="{x:Type igDP:LabelPresenter}"><StackPanel Orientation="Horizontal" HorizontalAlignment="Left">

<Button x:Name="BtnSelectAllUsersOnGroup" Style="{orbitui:SkinResource PermitAllButtonStyle}" DataContext="{Binding Path=DataPresenter}" Content="{loc:Resource Uid=SelectAll}" Click="BtnSelectAllUsersOnGroup_Click"></Button>

 

 

 

 

<Button x:Name="BtnClearAllOnGroup" Style="{orbitui:SkinResource PermitAllButtonStyle}"

 

 

 

DataContext="{Binding Path=DataPresenter.ActiveRecord}"Content="{loc:Resource Uid=ClearAll}" Click="BtnClearAllOnGroup_Click"></Button></StackPanel></ControlTemplate></Setter.Value>

 

 

 

 

</Setter></Style>

and on Click event i write the follwing code.

private

 

void BtnClearAllOnGroup_Click(object sender, RoutedEventArgs e){

var source = ((Button)sender); var record = source.DataContext as Record;

 

 

 //Here i found source.DataContext == null

This was not null and giving Record in DataContext but now in new version 2009.2 this is null,

I theer any way i can access to a record groupby value(the value on which the records are grouped.?

Any help would be gr8

 

 

Aqeel.