Add links to each step's code in the tutorial (#955)
* adjust code; add link to sample * Update gitignore to include vscode * Update AllNotes.cs
This commit is contained in:
Родитель
1713c129c6
Коммит
4746bae730
|
@ -6,6 +6,7 @@ _site/
|
|||
_themes*/
|
||||
_repo.*/
|
||||
.vs/
|
||||
.vscode/
|
||||
|
||||
.openpublishing.buildcore.ps1
|
||||
.DS_Store
|
||||
|
|
|
@ -238,7 +238,7 @@ Currently the **note** view displays a single note, and there isn't a view that
|
|||
01. In the **Solution Explorer** pane, right-click on the **Views** folder and select **Add** > **New Item...**
|
||||
01. In the **Add New Item** dialog, select **.NET MAUI** in the template list on the left-side of the window. Next, select the **.NET MAUI ContentPage (XAML)** template. Name the file _AllNotesPage.xaml_, and then select **Add**.
|
||||
01. In the **Solution Explorer** pane, right-click on the **Models** folder and select **Add** > **Class...**
|
||||
01. Name the class **AllNotes.cs** and press **Add**.
|
||||
01. Name the class _AllNotes.cs_ and press **Add**.
|
||||
|
||||
### Code the AllNotes model
|
||||
|
||||
|
@ -337,3 +337,5 @@ The `Routing.RegisterRoute` method takes two parameters:
|
|||
- The second parameter is the type of page to load when `"NotePage"` is navigated to.
|
||||
|
||||
Now you can run your app. Try adding new notes, navigating back and forth between notes, and deleting notes.
|
||||
|
||||
[![Explore the code.](~/media/code-sample.png) Explore the code for this step of the tutorial.](https://github.com/dotnet/maui-samples/tree/main/6.0/Tutorials/CreateNetMauiApp/step4)
|
||||
|
|
|
@ -94,3 +94,5 @@ Now that **note page** is finished, you need a way to present it to the user. Op
|
|||
Save the file and run the app. Try typing into the entry box and press the **Save** button. Close the app, and reopen it. The note you entered should be loaded from the device's storage.
|
||||
|
||||
:::image type="content" source="../media/note/final.png" alt-text="Note entry page in .NET MAUI app.":::
|
||||
|
||||
[![Explore the code.](~/media/code-sample.png) Explore the code for this step of the tutorial.](https://github.com/dotnet/maui-samples/tree/main/6.0/Tutorials/CreateNetMauiApp/step3)
|
||||
|
|
|
@ -28,3 +28,5 @@ Set the **Debug Target** in the Visual Studio toolbar to the device you want to
|
|||
01. Select the **Debug Target** dropdown button.
|
||||
01. Select the **Android Emulators** item.
|
||||
01. Select the emulator device.
|
||||
|
||||
[![Explore the code.](~/media/code-sample.png) Explore the code for this step of the tutorial.](https://github.com/dotnet/maui-samples/tree/main/6.0/Tutorials/CreateNetMauiApp/step1)
|
||||
|
|
|
@ -147,3 +147,5 @@ You'll see that there are two tabs: **Notes** and **About**. Press the **About**
|
|||
Close the app and return to Visual Studio. If you're using the Android emulator, terminate the app in the virtual device or press the stop button at the top of Visual Studio:
|
||||
|
||||
:::image type="content" source="../media/shell/vs-stop-button.png" alt-text="Visual Studio's stop debugging button.":::
|
||||
|
||||
[![Explore the code.](~/media/code-sample.png) Explore the code for this step of the tutorial.](https://github.com/dotnet/maui-samples/tree/main/6.0/Tutorials/CreateNetMauiApp/step2)
|
||||
|
|
|
@ -14,7 +14,7 @@ internal class AllNotes
|
|||
Notes.Clear();
|
||||
|
||||
// Get the folder where the notes are stored.
|
||||
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string appDataPath = FileSystem.AppDataDirectory;
|
||||
|
||||
// Use Linq extensions to load the *.notes.txt files.
|
||||
IEnumerable<Note> notes = Directory
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class NotePage : ContentPage
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string appDataPath = FileSystem.AppDataDirectory;
|
||||
string randomFileName = $"{Path.GetRandomFileName()}.notes.txt";
|
||||
|
||||
LoadNote(Path.Combine(appDataPath, randomFileName));
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Notes;
|
|||
//<filename_variable>
|
||||
public partial class NotePage : ContentPage
|
||||
{
|
||||
string _fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "notes.txt");
|
||||
string _fileName = Path.Combine(FileSystem.AppDataDirectory, "notes.txt");
|
||||
//</filename_variable>
|
||||
|
||||
//<load_note>
|
||||
|
|
Загрузка…
Ссылка в новой задаче