BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<syncfusion:SfDataGrid x:Name="gridSaved" Margin="452,10,10,0" VerticalAlignment="Top" Height="405" AutoGenerateColumns="False" ColumnSizer="Auto" ItemsSource="{Binding EditedForms}"> <syncfusion:SfDataGrid.Columns> <syncfusion:GridTextColumn HeaderText="Form" MappingName="Name" /> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid>
public void RefreshSavedFolder() { EditedForms.Clear(); DirectoryInfo dInfo = new DirectoryInfo(SavedPath); foreach (FileInfo file in dInfo.GetFiles()) { EditedForms.Add(new FormTemplate(file.Name, file.DirectoryName, file.FullName)); }
Hi Biju Vargheese,
Thank you for using Syncfusion products.
We have analyzed your query. Based on your code snippet, we are unable to find the collection type you are using whether it is List, ObservableCollection. If you are using ObservableCollection which implements INotifyCollectionChanged interface, SfDataGrid will be refreshed for Add and Remove operations in collection. If you are using List collection which does not implement the INotifyCollectionChanged interface, you can manually refresh the using below code snippet (using SfDataGrid.View.BeginInit() , SfDataGrid.View.EndInit() and SfDataGrid.View.Refresh() methods)
Code Snippet for Refresh the View if you are using List:
//When BeginInit method is called it suspends all the updates until EndInit method is called sfdatagrid.View.BeginInit(); viewmodel.Products.Clear(); viewmodel.Products.Add(new Product("P1", "HardWare", 1, "Jon")); viewmodel.Products.Add(new Product("P2", "Software", 2, "Jhon")); viewmodel.Products.Add(new Product("P3", "HardWare", 3, "Michel")); sfdatagrid.View.EndInit(); sfdatagrid.View.Refresh(); |
Please let us know if you have any other queries.
Regards,
Gobikrishnan M
public ObservableCollection<FormTemplate> EditedForms { get; private set; }
foreach (FileInfo file in dInfo.GetFiles()) { EditedForms.Add(new FormTemplate(file.Name, "Saved", file.DirectoryName)); }
Hi Biju,
We have analyzed your query. As mentioned in our previous update, in Observable collection, the collection itself implements the INotifyCollectionChanged interface. So SfDataGrid will be refreshed automatically for Add, Remove and Clear operations in collection. Based on your code snippet, we have prepared a sample and it can be downloaded from the following location.
In this sample, we have performed the operations like clearing the items and add new items in collection as you updated, but our SfDataGrid refreshed automatically. Could you please update more information on reported problem like modifying the above sample or provide issue reproducing sample to us? It would be better for us and provide a better solution.
Please let us know if you require further assistance on this.
Regards,
Gobikrishnan M
var formUser = (FormUser) gridSaved.DataContext; formUser.EditedForms.Clear();