The cell in the DataGrid correctly updates if I change the value of the property in the code, but the value of the property does not change if I modify the value in the cell itself. In fact, if I modify the value in the cell, it immediately returns to the value it was set to before that.

I'm working on an app where you can set TV episode rating data, and I'm using this datagrid for that purpose. Here is the relevant XAML:

<Grid > <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Text="Edit Ratings" FontSize="36" Margin="10" TextAlignment="Center"/> <controls:DataGrid ItemsSource="{x:Bind NetworkRatings}" Margin="10" AutoGenerateColumns="False" FrozenColumnCount="1" Grid.Row="1"> <controls:DataGrid.Columns> <controls:DataGridTextColumn Header="Show Name" Binding="{Binding ShowName}"/> <controls:DataGridTextColumn Header="Episode 1" Binding="{Binding Episode1, Mode=TwoWay, TargetNullValue='null', UpdateSourceTrigger=PropertyChanged}"/> </controls:DataGrid.Columns> </controls:DataGrid> </Grid>

I've changed the TargetNullValue to make the null values more obvious while I test the app, but in the end it will be a blank cell. Here is the code behind for the page:

public sealed partial class EditRatings : Page { ObservableCollection<RatingsContainer> NetworkRatings; Network network; public EditRatings() { this.InitializeComponent(); } protected override void OnNavigatedTo(NavigationEventArgs e) { network = (Network)e.Parameter; NetworkRatings = network.NetworkRatings; } }

and here is the RatingsContainer Class

class RatingsContainer : INotifyPropertyChanged { public string ShowName { get; } List<double?> Ratings; public double? Episode1 { get { return Ratings[0]; } set { Ratings[0] = value; OnPropertyChanged("Episode1"); } } public RatingsContainer(Show s) { ShowName = s.name; Ratings = s.ratings; //List of 26 double? values } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string name) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(name)); } } }

So far I've only been working on one episode out of the 26. I originally just wanted to work straight on the list or on an array, but I couldn't figure out how to do the propertynotify on something like that so I decided to separate them all out into their own properties in the end.

So the PropertyNotify seems to be working fine as I can update the property from the code behind and it will automatically refresh with the new value on the datagrid. However, for some reason, modifying the cell directly in the datagrid does not appear to be triggering the set method for the property at all. Am I missing something super obvious here? If I make the ShowName property settable, that modifies just fine. If I make the Episode1 property a regular double instead of nullable double, it also works fine, but I need that null value to represent episodes that have no ratings yet. As I start out with a null value, when I change the value in the cell, and click over to another cell, it immediately returns to null. If I start out with a value, or programmatically set a value, then it will automatically switch back to that value after I type something else in.

For reference, this is my first UWP app, with only limited experience working with WPF before that many years ago. It wouldn't surprise me if I missed something obvious but I've been googling this issue all night without much success. It seems my specific issue is either difficult to find or not very common.