0
我有一個Datagrid的列屬性必須在更改時自動保存。我正在使用ISOLATED STORAGE Settings來實現此目的。截至目前,我正在存儲DataGrid列的DISPLAY INDEX屬性。保存DataGridColumn排序屬性到獨立存儲
在我後面的代碼我試圖與DataGridName一起推動設置如下
List<GridColumnSettings> settings = new List<GridColumnSettings>();
for (int index = 0; index < dcDataGrid.Columns.Count; index++)
{
DataGridColumn column = dcDataGrid.Columns[index];
SettingsViewModel.GridColumnSettings setting = new GridColumnSettings(column.DisplayIndex, index);
settings.Add(setting);
}
**SendTemplatesSettingsViewModel.SaveSettings(settings, "dcBrowserDataGrid")**
的SaveSettings方法如下鏈接纔可這個
public class SendTemplatesSettingsViewModel
{
public class GridColumnSettings
{
public int Index { get; set; } //Managing the column ordering of the DataGrid
public int DisplayIndex { get; set; } //Store the Index/order of the column in the underlying datasource/ViewModel.
public GridColumnSettings(int columnIndex, int displayIndex)
{
this.DisplayIndex = columnIndex;
this.Index = displayIndex;
}
}
public void SaveSettings(List<SendTemplatesSettingsViewModel.GridColumnSettings> settings, string gridName)
{
mySettings.SetSetting<List<GridColumnSettings>>(gridName, settings);
}
的SetSettings方法只是實例化的獨立存儲並添加值。
我也想存儲排序順序的列,但我無法找到正確的屬性來這樣做。希望任何人都能幫忙。提前致謝。