2011-06-01 53 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... 
    }