The change tracking proxies from this topic solved my problem
https://learn.microsoft.com/ru-ru/ef/core/change-tracking/change-detection
Этот браузер больше не поддерживается.
Выполните обновление до Microsoft Edge, чтобы воспользоваться новейшими функциями, обновлениями для системы безопасности и технической поддержкой.
I have a View Model for a Wpf application
public class ProductVM: ViewModelBase, IProductVM
{
public ProductVM(IProductModel Repository)
{
this.Repository = Repository;
ProductDataList = Repository.ProductCollections;
if(ProductDataList.Count() > 0)
Selected = ProductDataList[0];
}
public IReadOnlyObservableCollection<IProduct> ProductDataList { get => Get<IReadOnlyObservableCollection<IProduct>>(); set => Set(value); }
IProductModel Repository { get; set; }
public IProduct Selected { get => Get<IProduct>(); set => Set(value); }
private ICommand _Add;
public ICommand Add => _Add ?? new RelayCommand(AddExcute);
private void AddExcute()
{
Selected.Name = "RRRRRRRRRRRRRRRR";
}
}
I get the data for the Product Data List like this
public IReadOnlyObservableCollection<TTarget> ToObservableCollections()
{
set.Load();
IReadOnlyObservableCollection<TTarget>? collection;
var list = set.Local.ToObservableCollection();
collection = new ReadOnlyObservableList<TTarget, TSource>(list);
return collection;
}
If I make changes to the View in Selected it is displayed. But I don't understand how I can make changes from the code appear in the View when calling the Add command, tell me what I can do or what to use
Just in case, I'll indicate how I use the binding
<ListBox x:Name="LbProduct"
Grid.Column="1"
Margin="1 0 0 0"
ItemsSource="{Binding ProductDataList}"
SelectedItem="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type model:IProduct}">
<StackPanel>
<TextBlock Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
<TextBlock Margin="0 4 0 0" Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The change tracking proxies from this topic solved my problem
https://learn.microsoft.com/ru-ru/ef/core/change-tracking/change-detection
Hello, This is a Russian speaking Q&A. Would you like to continue working on your issue in Russian? In case you wish to continue in English, you may ask your question on the English Q&A: https://learn.microsoft.com/en-us/answers/