How to prevent datagrid from updating data?

Here's the script:

  • Two toolkit data grids, side by side
  • Grid A is read-only and cannot be changed.
  • Grid B content can be modified and saved using the save button below it.

I need Grid A to remain unchanged until the user clicks the save button, regardless of any changes. In Grid B, it may or may not be. When I snap to the property below, both grids change when Grid B changes. I want to avoid this.

What is the best approach for this? Both grids are currently tied to the following property:

    public EntitySet<SomeEntity> SomeEntities
    {
        get { return _entity; }
        set
        {
            if (_entity != value)
            {
                _entity= value;
                OnPropertyChanged("SomePropertyChanged");
            }
        }
    }
+3
source share
4 answers

I tried using the DataGridTemplateColumn with OneTime binding. For instance,

<sdk:DataGridTemplateColumn>
    <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
             <TextBlock Text="{Binding Enabled, Mode=OneTime}"></TextBlock> 
        </DataTemplate>
    </sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
0

Grid A OneTime.

.

Text="{Binding Path=Age, Mode=OneTime}" 
+2

Perhaps instead of completely disabling the SomeEntities collection with which the Grid is bound, it is possible to use an ObservableCollection and then update for each position in the ObservableCollection. Then use Mode = OneTime, which Derek talks about.

+2
source

You can create two EntitySets, one for each DataGrid. After saving, you need to update the read-only dataset bound to the DataGrid.

0
source

All Articles