Hello,
We're trying to deselect all selected records when the user clicks anything but a record.
For example, in the attached image, if the user clicks the circled area, the parent record ("Biography") is selected. We would like to deselect all records when this happens.
Any ideas?
Thanks,
Matt
Hello Matt,
You can try handling the PreviewMouseLeftButtonDown event of the XamDataGrid and see if you can find a DataRecordCellArea element. If none is found, you can deselect all records, something like this:
void xamDataGrid1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DataRecordCellArea area = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject,
typeof(DataRecordCellArea), false) as DataRecordCellArea;
if (area == null)
xamDataGrid1.SelectedItems.Records.Clear();
}
Thanks for the response,
I have tried what you provided, also by just using "xamDataGrid1.SelectedItems.Records.Clear();" in a button.
Both seem to not work.
Matt.
Matt,
I did test this and it was working correctly. Can you please provide the sample that you are using and this is not having the desired effect?
Alex
When I click the area mentioned above it still selects a parent record or does not deselect an item.
For some reason when a member is clicked, "dgLeft.SelectedItems.Records" is empty. even when I did not apply your code.
<igDP:XamDataGrid InitializeRecord="xamDataGrid1_InitializeRecord" RecordExpanding="xamDataGrid1_RecordExpanding" RecordExpanded="xamDataGrid1_RecordExpanded" MouseDown="dgLeft_MouseDown" RecordsInViewChanged="dgLeft_RecordsInViewChanged" Margin="12,52.5,259,12" x:Name="dgLeft" GroupByAreaLocation="None" ScrollingMode="Immediate" PreviewMouseMove="dgLeft_PreviewMouseMove" PreviewMouseLeftButtonDown="dgLeft_PreviewMouseLeftButtonDown" MouseDoubleClick="xamDataGrid1_MouseDoubleClick" RecordLoadMode="LoadOnDemand" SnapsToDevicePixels="True" AllowDrop="True"> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" AllowGroupBy="False" AllowResize="False" AllowSummaries="False" CellClickAction="SelectRecord" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="Name"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource folderCell}" CellWidth="250" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="ID" Visibility="Collapsed" /> <igDP:Field Name="ParentID" Visibility="Collapsed" /> <igDP:Field Name="IsFolder" Visibility="Collapsed" /> <igDP:Field Name="FirstSeen" Visibility="Collapsed" /> <igDP:Field Name="IsAdded" Visibility="Collapsed" /> <igDP:Field Name="HasAddedChildren" Visibility="Collapsed" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="True" LabelLocation="Hidden" HeaderPlacement="OnTopOnly" SelectionTypeRecord="Default" RecordSelectorLocation="None" ExpansionIndicatorDisplayMode="CheckOnDisplay" /> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
DataRecordCellArea area = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(DataRecordCellArea), false) as DataRecordCellArea; if (area == null) dgLeft.SelectedItems.Records.Clear();
For the Microsoft.Windows.Themes.ScrollChrome element you need explicitly to add a reference to the PresentationFramework.Luna.dll. The Visual Studio will not do that for you, as it does for in other cases.
To make it scroll, you just have to remove e.Handled=true as this is preventing it.
Shoot,
I just noticed, that if you click a scroll bar.. the bar will not scroll.
I tryed:
Microsoft.Windows.Themes.ScrollChrome sc = Infragistics.Windows.Utilities.GetAncestorFromType( e.OriginalSource as DependencyObject, typeof(Microsoft.Windows.Themes.ScrollChrome), true) as Microsoft.Windows.Themes.ScrollChrome; // If clicking on the Scroll bar - do nothing if (sc != null) return;
but there is no such "Microsoft.Windows.Themes.ScrollChrome"
which if u put your mouse over the scroll bar and use a breakpoint.. you can see that is what the system recognises it as.
Thanks, Matt.
Thanks much, works great!
-Matt.
I now realized from your first screenshot that you are using 9.1 version - in 9.2 we have bubbles :) . So here it is why it's working with me and not with you:
In 9.2, we are not using nested panels for the nested records. So, when I am clicking beside the record, it returns null. In 9.1, this returns the presenter of the parent record, because it surrounds the nested records. That is why the parent record is selected. This however would require some more if-s, because you need to be sure when to deselect the record - basically in all the cases that you would not select it.
Here is a sample code snippet. Please test/run it and let me know of the result:
RecordSelector rs = Infragistics.Windows.Utilities.GetAncestorFromType(
e.OriginalSource as DependencyObject,
typeof(RecordSelector), true) as RecordSelector;
// If clicking on the record selector - do nothing
if (rs != null)
return;
ExpansionIndicator expInd = Infragistics.Windows.Utilities.GetAncestorFromType(
typeof(ExpansionIndicator), true) as ExpansionIndicator;
// If clicking on the expansion indicator - do nothing
if (expInd != null)
CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(
typeof(CellValuePresenter), true) as CellValuePresenter;
// If clicking in the cells - do nothing
if (cvp != null)
// Finally check for the area and deselect the record
DataRecordCellArea area = Infragistics.Windows.Utilities.GetAncestorFromType(
typeof(DataRecordCellArea), true) as DataRecordCellArea;
xamDataGrid1.ExecuteCommand(DataPresenterCommands.ClearAllSelected);
xamDataGrid1.ActiveRecord = null;
e.Handled = true;
I noticed that as well. I am going to look into this and update this thread when I have more information on it.