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
1253
INotifyPropertyChanged does not get updated
posted

Hi,

I have a child window where I put a simple XamWebGrid containing 3 TextColumns.  I have an ObservableCollection named Person:

 

private string _firstname;

 

private string _lastname;

 

private string _phone;

 

 

public string FirstName

{

 

get { return _firstname; }

 

set

{

 

if (value != _firstname)

{

_firstname =

value;

onPropertyChanged(

this, "UserFirstName");

}

}

}

 

public string LastName

{

 

get { return _lastname; }

 

set

{

 

if (value != _lastname)

{

_lastname =

value;

onPropertyChanged(

this, "UserLastName");

}

}

}

 

public string Phone

{

 

get { return _phone; }

 

set

{

 

if (value != _phone)

{

_phone =

value;

onPropertyChanged(

this, "Phone");

}

}

}

 

public event PropertyChangedEventHandler PropertyChanged;

 

public void onPropertyChanged(object sender, string propertyName)

{

 

if (PropertyChanged != null)

{

PropertyChanged(

this, new PropertyChangedEventArgs(propertyName));

}

}

The following code is how I populate the data:

 

 

 

 

 

 

 

 

person.Add(

 

new Person()

{

FirstName =

"Tom",

LastName =

"Jones",

Phone =

"1234"});

person.Add(

new Person()

{

FirstName =

"Karen",

LastName =

"AAA",

Phone =

"87645"});

 

grdPerson.ItemsSource = person;

 

Below is my Xaml code:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<igGrid:XamWebGrid x:Name="grdPerson" AutoGenerateColumns="False" Grid.Column="0" Grid.Row="0" Visibility

="Visible" >

 

 

 

<igGrid:XamWebGrid.Columns

>

 

 

 

<igGrid:TextColumn Width="200" Key="FirstName" IsReadOnly="True" Visibility

="Visible" >

 

 

 

<igGrid:TextColumn.HeaderTemplate

>

 

 

 

<DataTemplate

>

 

 

 

<TextBlock Text="First Name" TextWrapping="Wrap"

/>

 

 

 

</DataTemplate

>

 

 

 

</igGrid:TextColumn.HeaderTemplate

>

 

 

 

</igGrid:TextColumn

>

 

 

 

<igGrid:TextColumn Width="225" Key="LastName" HeaderText="Last Name" IsReadOnly

="False">

 

 

 

<igGrid:TextColumn.HeaderTemplate

>

 

 

 

<DataTemplate

>

 

 

 

<TextBlock Text="Last Name" TextWrapping

="Wrap" />

 

 

 

</DataTemplate

>

 

 

 

</igGrid:TextColumn.HeaderTemplate

>

 

 

 

</igGrid:TextColumn

>

 

 

 

<igGrid:TextColumn Width="225" Key="Phone" HeaderText="Phone" IsReadOnly

="False">

 

 

 

<igGrid:TextColumn.HeaderTemplate

>

 

 

 

<DataTemplate

>

 

 

 

<TextBlock Text="Phone" TextWrapping

="Wrap" />

 

 

 

</DataTemplate

>

 

 

 

</igGrid:TextColumn.HeaderTemplate

>

 

 

 

</igGrid:TextColumn

>

 

 

 

</igGrid:XamWebGrid.Columns

>

 

 

 

<igGrid:XamWebGrid.EditingSettings

>

 

 

 

<igGrid:EditingSettings AllowEditing="Row" IsEnterKeyEditingEnabled="True"

 

 

IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True"

/>

 

 

 

</igGrid:XamWebGrid.EditingSettings

>

 

 

 

<igGrid:XamWebGrid.SelectionSettings

>

 

 

 

<igGrid:SelectionSettings CellClickAction="SelectRow" RowSelection="Single"></igGrid:SelectionSettings

>

 

 

 

</igGrid:XamWebGrid.SelectionSettings

>

 

 

 

</igGrid:XamWebGrid

>

To view the upated phone data changed, I have this code:

 

var qry = from rec1 in person

 

select rec1;

 

foreach (var item in qry)

{

 

MessageBox.Show("first phone " + item.Phone);

}

When I tried to change the phone numbers on both records, only the first record gets changed but not on the second one.  I noticed this only happen on the child window.  Can anyone help on this?  Thanks!