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!

Parents
No Data
Reply
  • 6912
    posted

    Hi,

    I've tried to reproduce the issue using the code from your post but without success.

    Could you attach a sample that reproduces the issue?

    Also, what version and build of the product do you use (for example: 10.1.20101.2232)?

    Regards

Children