You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/samples/todoapp/wpf.md
+64-37Lines changed: 64 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,44 +2,71 @@
2
2
title = "WPF"
3
3
+++
4
4
5
-
You can find [our sample TodoApp for WPF](https://github.com/CommunityToolkit/Datasync/tree/main/samples/todoapp/TodoApp.WPF) on our GitHub repository. All of our logic has been placed in the `Database/AppDbContext.cs` file:
throw new ApplicationException($"Pull failed: {pullResult.FailedRequests.FirstOrDefault().Value.ReasonPhrase}");
34
-
}
35
-
}
36
-
}
37
-
{{< /highlight >}}
7
+
The WPF sample uses an in-memory Sqlite store for storing its data. To run the application locally:
8
+
9
+
*[Configure Visual Studio for WPF development](https://learn.microsoft.com/visualstudio/get-started/csharp/tutorial-wpf).
10
+
* Open `samples/todoapp/Samples.TodoApp.sln` in Visual Studio.
11
+
* In the Solution Explorer, right-click the `TodoApp.WPF` project, then select **Set as Startup Project**.
12
+
* Select a target (in the top bar), then press F5 to run the application.
13
+
14
+
If you bump into issues at this point, ensure you can properly develop and run WPF applications outside of the datasync service.
15
+
16
+
## Deploy a datasync server to Azure
17
+
18
+
Before you begin adjusting the application for offline usage, you must [deploy a datasync service](../server.md). Make a note of the URI of the service before continuing.
19
+
20
+
## Update the application for datasync operations
21
+
22
+
All the changes are isolated to the `Database/AppDbContext.cs` file.
23
+
24
+
1. Change the definition of the class so that it inherits from `OfflineDbContext`:
Replace the Endpoint with the URI of your datasync service.
48
+
49
+
3. Update the `SynchronizeAsync()` method.
50
+
51
+
The `SynchronizeAsync()` method is used by the application to synchronize data to and from the datasync service. It is called primarily from the `MainViewModel` which drives the UI interactions for the main list.
We have placed a `SynchronizeAsync()` method on the database context, which is used in the view model for the single page we have.
72
+
Obviously, youwillwanttodomuchmoreina"real world"application, includingpropererrorhandling, authentication, andusing a Sqlite file instead of an in-memory database. This example shows off the minimum required to add datasync services to an application.
0 commit comments