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
The MAUI sample uses an in-memory Sqlite store for storing its data. To run the application locally:
8
+
9
+
*[Configure Visual Studio for MAUI development](https://learn.microsoft.com/dotnet/maui/get-started/installation).
10
+
* Open `samples/todoapp/Samples.TodoApp.sln` in Visual Studio.
11
+
* In the Solution Explorer, right-click the `TodoApp.MAUI` project, then select **Set as Startup Project**.
12
+
* Select a target (in the top bar), then press F5 to run the application.
13
+
14
+
The application runs on Android, iOS, and Windows. Each platform needs slightly different setup. Read the MAUI documentation for more information.
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.
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.
Copy file name to clipboardExpand all lines: docs/content/samples/todoapp/winui3.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 = "WinUI3"
3
3
+++
4
4
5
-
You can find [our sample TodoApp for WinUI3](https://github.com/CommunityToolkit/Datasync/tree/main/samples/todoapp/TodoApp.WinUI3) 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 WinUI3 sample uses an in-memory Sqlite store for storing its data. To run the application locally:
8
+
9
+
*[Configure Visual Studio for WinUI3 development](https://learn.microsoft.com/windows/apps/get-started/start-here).
10
+
* Open `samples/todoapp/Samples.TodoApp.sln` in Visual Studio.
11
+
* In the Solution Explorer, right-click the `TodoApp.WinUI3` 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 WinUI3 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