I am new to WPF, and I am struggling on adding functionality on observable collections.
I have dropbox, datagrid and a list box.
Data grid and list boxes are binded to corresponding observable collections.
I want to add a listener to dropbox and the items in the list views.
Here is my sample code
XAML
<controls:SearchableDropBox DomainObject="{Binding ClassA}"
InputValidationManifest="{Binding ClassValidation, Mode=OneWay}"/>
<Custom:XamDataGrid DataSource="{Binding Path=ClassB.ClassList}"
GroupByAreaLocation="None" />
<controls:ListBox x:Name="listBoxInputs" ItemsSource="{Binding ClassC, Mode=oneWay}">
VIEMMODEL
class MainViewModel : ViewModel
{
#region Attributes
private classA _classa;
private ObservableCollection<classC> _classC;
private classB;
#endregion
public MainViewModel()
{
this._classc= new ObservableCollection<classC>();
this._classB = new classB()
}
public classA ClassA
{
get { return _classA; }
set
{
if (!Equals(value, _classA))
{
_classA= value;
SelectionChanged(); //This is the function I want add on //propertychanged event
OnPropertyChanged(nameof(classA));
}
}
}
public ObservableCollection<classC> ClassC
{
get { return classC; }
set
{
this.classC= value;
OnPropertyChanged(nameof(ClassC));
}
}
ClassB
public class classB
{
private ObservableCollection<String> _classList;
}
I want to call SelectionChanged() function when the selection of the dropbox, and when item added/deleted in list box without overriding their current notify property changed events.
For add/Remove in _classC collection, you subscribe to CollectionChanged event.
public MainViewModel()
{
this._classc= new ObservableCollection<classC>();
this._classB = new classB()
_classC.CollectionChanged += _classC_CollectionChanged;
}
private void _classC_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
//Populate ClassB.ClassList / Datagrid Function Call
}
Related
I'm struggling to get the datagrid updated when I remove items from my ObservableCollection. When I remove them, the items in the ObservableCollection that is binded to the DataGrid are removed correctly but they still appear in the DataGrid.
This is my view:
<Grid>
<DataGrid x:Name="ContactsList" Margin="20" AutoGenerateColumns="False" IsReadOnly="True" CanUserResizeRows="False"
CanUserResizeColumns="True" ColumnWidth="*" ItemsSource="{Binding Contacts, UpdateSourceTrigger=PropertyChanged, diag:PresentationTraceSources.TraceLevel=High}">
</DataGrid>
</Grid>
(columns are populated in the code-behind).
This is my view-model:
public class ContactsViewModel : BindableBase
{
private readonly IRegionManager regionManager;
private readonly IEventAggregator eventAggregator;
private readonly IConfigurationContactsService contactsService;
private readonly DelegateCommand<object> deleteContactCommand;
private ObservableCollection<Contact> contactsCollection;
private ICollectionView contactsView;
public ContactsViewModel(IEventAggregator eventAggregator, IConfigurationContactsService contactsService, IRegionManager regionManager)
{
this.regionManager = regionManager;
this.contactsService = contactsService;
this.eventAggregator = eventAggregator;
this.deleteContactCommand = new DelegateCommand<object>(this.DeleteContact, this.CanDeleteContact);
this.contactsCollection = new ObservableCollection<Contact>(contactsService.GetContacts());
this.contactsView = CollectionViewSource.GetDefaultView(this.contactsCollection);
}
public ICollectionView ContactsView
{
get { return this.contactsView; }
}
public ObservableCollection<Contact> Contacts
{
get { return this.contactsCollection; }
}
public ICommand DeleteContactCommand
{
get { return this.deleteContactCommand; }
}
private void DeleteContact(object ignore)
{
IList<Contact> selectedContacts = contactsService.GetSelectedContacts();
foreach (Contact contact in selectedContacts)
{
if (contact != null)
{
contactsService.DeleteContact(contact);
}
}
SetProperty<ObservableCollection<Contact>>(ref this.contactsCollection, new ObservableCollection<Contact>(contactsService.GetContacts()), "Contacts");
// After this, the observable collection is updated correctly, but the datagrid does not delete the items.
}
private bool CanDeleteContact(object ignored)
{
return contactsService.GetSelectedContacts().Any();
}
}
I can't see where the error is. Can anyone spot the error? Thanks in advance.
EDIT
There is one peculiarity on this view. There is a Main View with a toolbar (where the delete button is), and a ContentTab region that holds two views: View A, View B). The DataGrid is located in View A, and all thre views (A, B and MainView) have the same viewmodel: ContactsViewModel.
Why are you binding to the ObservableCollection when you have a ICollectionView property?. Anyway, this should refresh the binding to the ObservableCollection:
private void DeleteContact(object ignore)
{
IList<Contact> selectedContacts = contactsService.GetSelectedContacts();
foreach (Contact contact in selectedContacts)
{
if (contact != null)
{
contactsService.DeleteContact(contact);
}
}
contactsCollection = new ObservableCollection<Contact>(contactsService.GetContacts());
this.OnPropertyChanged("Contacts");
}
If the DataGrid doesn't get updated you need to verify that the contactsService.GetContacts() method returns the items that you expect it to return.
Edit: You also need to make sure the view binds to the same instance of the view model in which the DeleteContact method is executed. Put a breakpoint in the constructor of the view model and make sure that it gets hit only once. Then you know that there is only one instance created and that you bind to this one.
Observable collection already implements INotifyPropertyChanged, you don't have to do that again:
public ObservableCollection<Contact> Contacts{ get;}
private void DeleteContact(object ignore)
{
IList<Contact> selectedContacts = contactsService.GetSelectedContacts();
foreach (Contact contact in selectedContacts)
{
if (contact != null)
{
contactsService.DeleteContact(contact);
Contacts.Remove(contact);// HERE IS THE CHANGE
}
}
}
You only have to remove the old items, and add new items. No need for another instance.
EDIT:
To add new items, do the following:
Contacts.Add(newContact);
EDIT EDIT:
You might have to modify your deleting a little bit, try this:
Contacts.Remove(Contacts.FirstOrDefault(c=c.Id == contact.Id)); // HERE IS THE CHANGE
I don't know if you have an ID property in your contact class, if not then use something else to find the correct contact, eg. Name or Last name
I'm fairly novice with WPF. It's my understanding that data changes in the model, and it should notify the viewmodel, and the view will bind to properties and things alike in the viewmodel. Is this correct? If so, I've been reading that the model should implement INotifyPropertyChanged, and look something like this
public class LoginModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
public bool Authenticated { get; set; }
}
and in my ViewModel, I have a property "AuthResult", that should get the update from the Model property "Authenticated"
public partial class view1 : UserControl, INotifyPropertyChanged{
public bool AuthResult
{
get
{
return _authVal;
}
set
{
_authVal = value;
NotifyPropertyChanged("AuthResult");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
}
I know this current implementation is incorrect. I've found that I should be subscribing to the PropertyChanged notification from my model like so:
LoginModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(LoginModel_PropertyChanged);
void LoginModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if(e.PropertyName == "Authenticated")
{
//do something
}
}
I don't see where the "AuthResult" property should be updated. Would I do something in the If statement like AuthResult = _model.Authenticated;?
EDITED:
and in my constructor?
LoginModel _model;
public view1(LoginModel model)
{
_model = model;
InitializeComponent();
}
If the model implements the INotifyPropertyChanged interface you can bind directly to it from the view:
<Button Content="Button" IsEnabled="{Binding Authenticated}" />
Note that the LoginModel class must raise the PropertyChanged event whenever the Authenticated property is set to a new value.
You could also expose the entire model entity through the view model class:
public class ViewModel
{
public ViewModel(LoginModel model)
{
Model = model;
}
public LoginModel Model { get; }
}
...and bind to it like this:
<Button Content="Button" IsEnabled="{Binding Model.Authenticated}" />
It is still the model class that must implement the INotifyPropertyChanged interface and raise change notifications.
Another option is for the view model to wrap any property of the model class that you want to be able to bind to from the view. Then you bind to a property of the view model class that in turn wraps a property of the model class something like this:
public class ViewModel
{
private readonly LoginModel _model;
public ViewModel(LoginModel model)
{
_model = model;
}
public bool AuthResult
{
get
{
return _model.Authenticated;
}
set
{
_model.Authenticated = value;
NotifyPropertyChanged("AuthResult");
}
}
}
<Button Content="Button" IsEnabled="{Binding AuthResult}" />
The benefit of using this latter approach is that view has no dependency upon the model class. It binds to the view model class only and this is how the MVVM design pattern typically is meant to be implemented.
But if you do bind to a (wrapper) property of the view model and want the view to be updated whenever a property of the model class is set, the model has to notify the view model that it has changed one way or another, i.e. it has to raise some kind of event or similar. And this typically means implementing the INotifyPropertyChanged interface. The view model can then subscribe to the PropertyChanged event of the model and raise its own PropertyChanged event for the data bound property whenever the model is updated, e.g.:
public class ViewModel
{
private readonly LoginModel _model;
public ViewModel(LoginModel model)
{
if (model == null)
throw new ArgumentNullException("model");
_model = model;
_model.PropertyChanged += OnModelChanged;
}
private void OnModelChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Authenticated")
NotifyPropertyChanged("AuthResult");
}
public bool AuthResult
{
get
{
return _model.Authenticated;
}
set
{
_model.Authenticated = value;
NotifyPropertyChanged("AuthResult");
}
}
}
Just use Model as member in the ViewModel
public class ViewModel
{
private Model _myModel;
public Model MyModel
{
get { return _myModel; }
set
{
if (Equals(_myModel, value)) return;
_myModel = value;
NotifyPropertyChanged(nameof(MyModel));
}
}
}
Then in xaml you can bind properties of Model
<CheckBox IsChecked="{Binding MyModel.Authenticated}" />
With this approach your ViewModel will be "build" around your Model.
In case you don't want that models implement INotifyPropertyChanged than create a "Facade" class of model in use it in same way as previous example.
public class ModelFacade : INotifyPropertyChanged
{
private Model _myModel;
public bool Authenticated
{
get { return _myModel.Authenticated; }
set
{
_myModel.Authenticated = value;
NotifyPropertyChanged(nameof(Authenticated));
}
}
}
public class ViewModel
{
private ModelFacade _myModel;
public ModelFacade MyModel
{
get { return _myModel; }
set
{
if (Equals(_myModel, value)) return;
_myModel = value;
NotifyPropertyChanged(nameof(MyModel));
}
}
}
I need to update the list of downloads when the progress has been changed.
XAML:
<ListView ItemsSource="{Binding UiList}" x:Name="MyListView">
<ListView.View>
<GridView>
<GridViewColumn Header="Title"/>
<GridViewColumn Header="Progress"/>
</GridView>
</ListView.View>
</ListView>
ViewModel that creates an instance of Logic class and updates the content of ListView:
class MainWindowViewModel : ViewModelBase
{
private readonly Logic _logic;
public List<Model> UiList { get; set; }
public MainWindowViewModel()
{
_logic = new Logic();
_logic.Update += LogicUpdate;
Start = new RelayCommand(() =>
{
var worker = new BackgroundWorker();
worker.DoWork += (sender, args) => _logic.Start();
worker.RunWorkerAsync();
});
}
void LogicUpdate(object sender, EventArgs e)
{
UiList = _logic.List;
RaisePropertyChanged("UiList");
}
public ICommand Start { get; set; }
}
Logic:
public class Logic
{
readonly List<Model> _list = new List<Model>();
public event EventHandler Update;
public List<Model> List
{
get { return _list; }
}
public void Start()
{
for (int i = 0; i < 100; i++)
{
_list.Clear();
_list.Add(new Model{Progress = i, Title = "title1"});
_list.Add(new Model { Progress = i, Title = "title2" });
var time = DateTime.Now.AddSeconds(2);
while (time > DateTime.Now)
{ }
Update(this, EventArgs.Empty);
}
}
}
The code above would not update UI. I know two way how to fix this:
In xaml codebehind call: Application.Current.Dispatcher.Invoke(new Action(() => MyListView.Items.Refresh()));
In ViewModel change List<> to ICollectionView and use Application.Current.Dispatcher.Invoke(new Action(() => UiList.Refresh())); after the list has been updated.
Both ways cause the problem: the ListView blinks and Popup that should be open on user demand always closes after each "refresh":
<Popup Name="Menu" StaysOpen="False">
I can replace the popup with another control or panel, but I need its possibility to be out of main window's border (like on screen). But I believe that WPF has another way to update the content of ListView (without blinks).
PS: Sorry for long question, but I do not know how to describe it more briefly...
I think the reason this line doesn't work:
RaisePropertyChanged("UiList");
Is because you haven't actually changed the list. You cleared it and repopulated it, but it's still the reference to the same list. I'd be interested to see what happens if, instead of clearing your list and repopulating, you actually created a new list. I think that should update your ListView as you expected. Whether or not it has an effect on your popup, I don't know.
I've found the answer here: How do I update an existing element of an ObservableCollection?
ObservableCollection is a partial solution. ObservableCollection rises CollectionChanged event only when collection changes (items added, removed, etc.) To support updates of existent items, each object inside the collection (Model class in my case) must implement the INotifyPropertyChanged interface.
// I used this parent (ViewModelBase) for quick testing because it implements INotifyPropertyChanged
public class Model : ViewModelBase
{
private int _progress;
public int Progress
{
get { return _progress; }
set
{
_progress = value;
RaisePropertyChanged("Progress");
}
}
public string Title { get; set; }
}
I have a static collection of items (say numbers from 1 to 100) that I'm presenting in a ComboBox. I can bind these items to the ComboBox no problem.
My question is how to bind a second ComboBox to a subset of those items. The behavior I want is to have the second ComboBox bound to the subset of items remaining after the first ComboBox is selected. For example the first ComboBox would show 1,2,3...,100. If the number 43 is selected in the first ComboBox then the second ComboBox should show 44,45,...,100.
How can this be accomplished and have the second ComboBox update if the first is changed without a lot of code-behind?
I would do this with a using MVVM pattern.
Create a class that implements INotifyChange and expose three Property.
ICollection FullCollection
int FirstIndex
ICollection PartialCollection
Use this class as DataContext for your Control and bind SelectedIndex of the first combo box to FirstIndex property, ItemSource of first combobox to FullCollection and ItemSource of second collection to PartialCollection (Be sure that SelectedIndex binding mode is Two Way).
Then on set of FirstIndex property set the PartialCollection property as you want.
Remember that you have to use NotifyPropertyChange on set method of each Properties.
Hope this help.
I'd go with MVVM design but if you want to just do testing and want to see quick results without going into design patterns then I'd suggest using something like CLINQ / BLINQ / Obtics framework to leverege the power of LINQ while keeping the results live for the combo box.
Since LoSciamano has already posted a reply on that (while i was posting this!) I won't dive into details of MVVM implementation
I would expose the first collection as an ObservableCollection<T> and the second collection as a bare IEnumerable. You can then use the default collection view to handle the events necessary to re-filter the sub collection.
class FilteredVM : ViewModelBase
{
public ObservableCollection<MyVM> Items { get; private set; }
public IEnumerable<MyVM> SubItems { get; private set; }
public FilteredVM()
{
this.Items = new ObservableCollection<MyVM>();
this.SubItems = Enumerable.Empty<MyVM>();
var view = CollectionViewSource.GetDefaultView(this.Items);
view.CurrentChanged += (sender, e) => { SetupFilter(); };
view.CollectionChanged += (sender, e) => { SetupFilter(); };
}
private void SetupFilter()
{
var view = CollectionViewSource.GetDefaultView(this.Items);
var current = view.CurrentItem;
if (current != null)
{
this.SubItems = this.Items.Where((vm,idx) => idx > view.CurrentPosition);
}
else
{
this.SubItems = Enumerable.Empty<MyVM>();
}
this.OnPropertyChanged("SubItems");
}
}
Alternatively, if you'd like to keep CollectionViewSource out of your VM:
class FilteredVM : ViewModelBase
{
private MyVM selectedItem;
public MyVM SelectedItem
{
get { return this.selectedItem; }
set
{
if (value != this.selectedItem)
{
this.selectedItem = value;
this.OnPropertyChanged("SelectedItem");
this.SetupFilter();
}
}
}
public ObservableCollection<MyVM> Items { get; private set; }
public IEnumerable<MyVM> SubItems { get; private set; }
public FilteredVM()
{
this.Items = new ObservableCollection<MyVM>();
this.SubItems = Enumerable.Empty<MyVM>();
this.Items.CollectionChanged += (sender, e) => { this.SetupFilter(); };
}
private void SetupFilter()
{
if (this.SelectedItem != null)
{
var item = this.SelectedItem; // save for closure
this.SubItems = this.Items.SkipWhile(vm => vm != item).Skip(1);
}
else
{
this.SubItems = Enumerable.Empty<MyVM>();
}
this.OnPropertyChanged("SubItems");
}
}
Keep in mind this will require SelectedItem to be properly bound in the View to the ViewModel. The first approach listed allows the SelectedItem to be bound to anywhere (or nowhere).
Have 2 Observable collections so that when item in the 1st box is selected, it will kick off method which clears and re populates the 2nd collection. As it is observableCollection, it gets reflected in the WPF GUI automatically
Here is a concrete example (as usual, may be improved, but the idea is here) :
Code behind an view model :
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
DataContext = new ViewModel();
}
}
public class ViewModel : INotifyPropertyChanged
{
public ViewModel()
{
Initialsource = new ObservableCollection<int>();
for (int i = 0; i < 101; i++)
{
Initialsource.Add(i);
}
}
private int _selectedsourceItem;
public int SelectedsourceItem
{
get { return _selectedsourceItem; }
set
{
_selectedsourceItem = value;
SubsetSource = new ObservableCollection<int>(Initialsource.Where(p => p > _selectedsourceItem));
InvokePropertyChanged(new PropertyChangedEventArgs("SubsetSource"));
InvokePropertyChanged(new PropertyChangedEventArgs("SelectedsourceItem"));
}
}
private ObservableCollection<int> _initialsource;
public ObservableCollection<int> Initialsource
{
get { return _initialsource; }
set
{
_initialsource = value;
InvokePropertyChanged(new PropertyChangedEventArgs("Initialsource"));
}
}
private ObservableCollection<int> _subsetSource;
public ObservableCollection<int> SubsetSource
{
get { return _subsetSource ?? (_subsetSource = new ObservableCollection<int>()); }
set
{
_subsetSource = value;
InvokePropertyChanged(new PropertyChangedEventArgs("SubsetSource"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void InvokePropertyChanged(PropertyChangedEventArgs e)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, e);
}
}
XAML :
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<ComboBox Width="100" ItemsSource="{Binding Initialsource}" SelectedItem="{Binding SelectedsourceItem, Mode=TwoWay}"></ComboBox>
<ComboBox Width="100" ItemsSource="{Binding SubsetSource}"></ComboBox>
</StackPanel>
</Grid>
You can use my ObservableComputations library:
ObservableCollection<Item> itemsSubset = ItemsObservableCollection
.Skiping(fromIndex)
.Taking(itemsInSubsetCount);
itemsSubset reflacts all the changes in ItemsObservableCollection.
Project Overview
I have a view which binds to a viewmodel containing 2 ObserverableCollection. The viewmodel constructor populates the first ObserverableCollection and the view datacontext is collected to bind to it through a public property called Sites.
Later the 2ed ObserverableCollection is populated in the LoadOrders method and the public property LoadFraudResults is updated for binding it with datacontext.
I am using WCF to pull the data from the database and its getting pulled very nicely.
VIEWMODEL SOURCE
class ManageFraudOrderViewModel:ViewModelBase
{
#region Fields
private readonly ICollectionView collectionViewSites;
private readonly ICollectionView collectionView;
private ObservableCollection<GeneralAdminService.Website> _sites;
private ObservableCollection<FraudService.OrderQueue> _LoadFraudResults;
#endregion
#region Properties
public ObservableCollection<GeneralAdminService.Website> Sites
{
get { return this._sites; }
}
public ObservableCollection<FraudService.OrderQueue> LoadFraudResults
{
get { return this._LoadFraudResults;}
}
#endregion
public ManageFraudOrderViewModel()
{
//Get values from wfc service model
GeneralAdminService.GeneralAdminServiceClient generalAdminServiceClient = new GeneralAdminServiceClient();
GeneralAdminService.Website[] websites = generalAdminServiceClient.GetWebsites();
//Get values from wfc service model
if (websites.Length > 0)
{
_sites = new ObservableCollection<Wqn.Administration.UI.GeneralAdminService.Website>();
foreach (GeneralAdminService.Website website in websites)
{
_sites.Add((Wqn.Administration.UI.GeneralAdminService.Website)website);
}
this.collectionViewSites= CollectionViewSource.GetDefaultView(this._sites);
}
generalAdminServiceClient.Close();
}
public void LoadOrders(Wqn.Administration.UI.FraudService.Website website)
{
//Get values from wfc service model
FraudServiceClient fraudServiceClient = new FraudServiceClient();
FraudService.OrderQueue[] OrderQueue = fraudServiceClient.GetFraudOrders(website);
//Get values from wfc service model
if (OrderQueue.Length > 0)
{
_LoadFraudResults = new ObservableCollection<Wqn.Administration.UI.FraudService.OrderQueue>();
foreach (FraudService.OrderQueue orderQueue in OrderQueue)
{
_LoadFraudResults.Add(orderQueue);
}
}
this.collectionViewSites= CollectionViewSource.GetDefaultView(this._LoadFraudResults);
fraudServiceClient.Close();
}
}
VIEW SOURCE
public partial class OrderQueueControl : UserControl
{
private ManageFraudOrderViewModel manageFraudOrderViewModel ;
private OrderQueue orderQueue;
private ButtonAction ButtonAction;
private DispatcherTimer dispatcherTimer;
public OrderQueueControl()
{
LoadOrderQueueForm();
}
#region LoadOrderQueueForm
private void LoadOrderQueueForm()
{
//for binding the first observablecollection
manageFraudOrderViewModel = new ManageFraudOrderViewModel();
this.DataContext = manageFraudOrderViewModel;
}
#endregion
private void cmbWebsite_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
BindItemsSource();
}
#region BindItemsSource
private void BindItemsSource()
{
using (OverrideCursor cursor = new OverrideCursor(Cursors.Wait))
{
if (!string.IsNullOrEmpty(Convert.ToString(cmbWebsite.SelectedItem)))
{
Wqn.Administration.UI.FraudService.Website website = (Wqn.Administration.UI.FraudService.Website)Enum.Parse(typeof(Wqn.Administration.UI.FraudService.Website),cmbWebsite.SelectedItem.ToString());
//for binding the second observablecollection*******
manageFraudOrderViewModel.LoadOrders(website);
this.DataContext = manageFraudOrderViewModel;
//for binding the second observablecollection*******
}
}
}
#endregion
}
XAML
ComboBox x:Name="cmbWebsite" ItemsSource="{Binding Sites}" Margin="5"
Width="100" Height="25" SelectionChanged="cmbWebsite_SelectionChanged"
DataGrid ItemsSource ={Binding Path = LoadFraudResults}
PROBLEM AREA:
When I call the LoadOrderQueueForm to bind the first observablecollection and later BindItemsSource to bind 2ed observable collection, everything works fine and no problem for the first time binding.
But, when I call BindItemsSource again to repopulate the obseravablecollection based on changed selected combo value via cmbWebsite_SelectionChanged, the observalblecollection gets populated with new value and LoadFraudResults property in viewmodule is populated with new values; but when i call the datacontext to rebind the datagrid,the datagrid does not reflect the changed values.
In other words the datagrid doesnot get changed when the datacontext is called the 2ed time in BindItemsSource method of the view.
manageFraudOrderViewModel.LoadOrders(website);
this.DataContext = manageFraudOrderViewModel;
manageFraudOrderViewModel values are correct but the datagrid is not relected with changed values.
Please help as I am stuck with this thing for past 2 days and the deadline is approaching near.
Thanks in advance
try to use datagrid.Items.Refresh() !
Yes, ilu2009 is correct.
Binding using the MVVM modal to a DataGrid and changing the objects in DataGrid.ItemsSource requires DataGrid.ItemsSource.Refresh() for it to reflect on the UI.