2011-06-01 52 views
6

有没有一种方法可以保存来自ListView的详细信息,不需要我每次都使用保存对话框并允许我在特定时间范围内调用它。因此,每次“保存”而不是“另存为”。自动保存 - WPF C#

回答

6

您可以使用DispatchTimer与回调方法来执行您的保存。

DispatcherTimer autosaveTimer = new DispatcherTimer(TimeSpan.FromSeconds(autosaveInterval), DispatcherPriority.Background, new EventHandler(DoAutoSave), Application.Current.Dispatcher); 

    private void DoAutoSave(object sender, EventArgs e) 
    { 
     // Enter save logic here... 
    }