North American Sales: 1-800-231-8588
Global Contacts
My Account
Menu
North American Sales: 1-800-321-8588
My Account
Sign In/Register
Design & Development
Design & Develop
Best Value
Infragistics Ultimate
The complete toolkit for building high performing web, mobile and desktop apps.
Indigo.Design
Use a unified platform for visual design, UX prototyping, code generation and application development.
Web
Ignite UI for Angular
Ignite UI for JavaScript
Ignite UI for React
Ultimate UI for ASP.NET
Indigo.Design
Desktop
Ultimate UI for Windows Forms
Ultimate UI for WPF
Prototyping
Indigo.Design
Mobile
Ultimate UI for Xamarin
Ultimate UI for iOS
Ultimate UI for Android
Automated Testing Tools
Test Automation for Micro Focus UFT: Windows Forms
Test Automation for Micro Focus UFT: WPF
Test Automation for IBM RFT: Windows Forms
UX
Indigo.Design Desktop
Collaborative prototyping and remote usability testing for UX & usability professionals
Indigo.Design
A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
Business Intelligence
Reveal Embedded
Accelerate your time to market with powerful, beautiful dashboards into your apps
Reveal App
Empower everyone in your organization to use data to make smarter business decisions
Team Productivity
Learn & Support
Support
Help & Support Documents
Blogs
Forums
Product Ideas
Reference Applications
Customer Stories
Webinars
eBook & Whitepapers
Events
Free Trials
Pricing
Product Pricing / Buy Online
Renew Existing License
Contact Us
Forums
Ultimate UI for WPF
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
Close
State
See Verified Answer
Replies
1 reply
Subscribers
6 subscribers
Views
2306 views
Users
0 members are here
XamDataGrid
Selection
Share
More
Cancel
130
XamdataGrid SelectedItem setter called with wrong value
Harry Harrison
posted
over 5 years ago
In the provided example, when the user clicks on a check box the SelectedItem's setter is called with a value of Null, which causes the application to lose track of the currently selected item.
You can reproduce the behavior by clicking "Parent B", expanding Parent A, then clicking the checkbox on Child A1. Note how SelectedItem becomes null.
I can partially solve the problem by setting CellClickAction="SelectRecord" but this forces the user to click the check box multiple times to change its value.
Is there a good solution that calls the setter with correct values and allows the user to check the checkbox with a single click? I am using version 18.1.
You can see a fuller description of the problem on my blog at
https://wpfthoughts.blogspot.com/2018/09/xamdatagrid-selecteditem-bug.html
<
Window
x
:
Class
="XamDataGridBadSelector.MainWindow"
xmlns
="
http://schemas.microsoft.com/winfx/2006/xaml/presentation
"
xmlns
:
x
="
http://schemas.microsoft.com/winfx/2006/xaml
"
xmlns
:
d
="
http://schemas.microsoft.com/expression/blend/2008
"
xmlns
:
mc
="
http://schemas.openxmlformats.org/markup-compatibility/2006
"
xmlns
:
local
="clr-namespace:XamDataGridBadSelector"
xmlns
:
igDP
="
http://infragistics.com/DataPresenter
"
mc
:
Ignorable
="d"
Title
="MainWindow"
Height
="350"
Width
="525"
DataContext
="{
Binding
RelativeSource
={
RelativeSource
Self
}}">
<
StackPanel
Orientation
="Vertical">
<
igDP
:
XamDataGrid
DataSource
="{
Binding
Parents
}"
SelectedDataItem
="{
Binding
SelectedItem
,
UpdateSourceTrigger
=PropertyChanged}"
GroupByAreaLocation
="None"
Height
="250">
<
igDP
:
XamDataGrid.FieldLayoutSettings
>
<
igDP
:
FieldLayoutSettings
SelectionTypeRecord
="Single"
AutoGenerateFields
="False"/>
</
igDP
:
XamDataGrid.FieldLayoutSettings
>
<
igDP
:
XamDataGrid.FieldSettings
>
<
igDP
:
FieldSettings
AllowSummaries
="False"
AllowEdit
="False"/>
</
igDP
:
XamDataGrid.FieldSettings
>
<
igDP
:
XamDataGrid.FieldLayouts
>
<
igDP
:
FieldLayout
Description
="Parents"
Key
="Parents">
<
igDP
:
TextField
Label
="Parent"
Name
="Description"/>
<
igDP
:
Field
Label
=""
Name
="Children"/>
</
igDP
:
FieldLayout
>
<
igDP
:
FieldLayout
ParentFieldLayoutKey
="Parents"
ParentFieldName
="Children">
<
igDP
:
FieldLayout.Fields
>
<
igDP
:
CheckBoxField
Label
="Smart"
Name
="IsChecked">
<
igDP
:
CheckBoxField.Settings
>
<
igDP
:
FieldSettings
AllowEdit
="True"/>
</
igDP
:
CheckBoxField.Settings
>
</
igDP
:
CheckBoxField
>
<
igDP
:
TextField
Label
="Child"
Name
="Description"/>
</
igDP
:
FieldLayout.Fields
>
</
igDP
:
FieldLayout
>
</
igDP
:
XamDataGrid.FieldLayouts
>
</
igDP
:
XamDataGrid
>
<
TextBlock
Text
="{
Binding
SelectedItem
.Description,
StringFormat
='Selected Parent is {0}'}"/>
</
StackPanel
>
</
Window
>
----------------------------------
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Windows;
namespace
XamDataGridBadSelector
{
public
partial
class
MainWindow
:
Window
,
INotifyPropertyChanged
{
public
class
cItem
{
public
bool
IsChecked {
get
;
set
; }
public
string
Description {
get
;
set
; }
public
List
<
cItem
> Children {
get
;
set
; }
}
public
List
<
cItem
> Parents {
get
;
set
; }
private
cItem
_SelectedItem;
public
cItem
SelectedItem
{
get
{
return
_SelectedItem; }
set
{ _SelectedItem =
value
; NotifyPropertyChanged(
"SelectedItem"
); }
}
public
MainWindow()
{
Parents =
new
List
<
cItem
>() {
new
cItem
() {Description=
"Parent A"
,
Children =
new
List
<
cItem
> {
new
cItem
() { Description=
"Child A1"
},
new
cItem
() { Description=
"Child A2"
}
} },
new
cItem
() {Description=
"Parent B"
,
Children =
new
List
<
cItem
> {
new
cItem
() { Description=
"Child B1"
},
new
cItem
() { Description=
"Child B2"
}
}
} };
InitializeComponent();
}
public
event
PropertyChangedEventHandler
PropertyChanged;
private
void
NotifyPropertyChanged(
String
info)
{
if
(PropertyChanged !=
null
)
{
PropertyChanged(
this
,
new
PropertyChangedEventArgs
(info));
}
}
}
}
Top Replies
34430
Offline
Andrew Goldenbaum
posted
over 5 years ago
+1
verified
Hello Harry, Thank you for your post. I'd like to preface the following by saying that the behavior you are seeing is actually expected. This is due...view reply »