-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added NotePage * Added content to NotePage.xaml * Added fuctionality to NotePage, added NotePage to AppShell
- Loading branch information
1 parent
f7c7042
commit e72e314
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Notes.NotePage" | ||
Title="Note"> | ||
<VerticalStackLayout Spacing="10" Margin="5"> | ||
<Editor x:Name="TextEditor" | ||
Placeholder="Enter your note" | ||
HeightRequest="100" /> | ||
|
||
<Grid ColumnDefinitions="*,*" ColumnSpacing="4"> | ||
<Button Text="Save" | ||
Clicked="SaveButton_Clicked" /> | ||
|
||
<Button Grid.Column="1" | ||
Text="Delete" | ||
Clicked="DeleteButton_Clicked" /> | ||
</Grid> | ||
</VerticalStackLayout> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Notes; | ||
|
||
public partial class NotePage : ContentPage | ||
{ | ||
string _fileName = Path.Combine(FileSystem.AppDataDirectory, "notes.txt"); | ||
//The code above constructs a path to the file, storing it in the app's local data directory. The file name is notes.txt. | ||
public NotePage() | ||
{ | ||
InitializeComponent(); | ||
//read the file from the device and store its contents in the TextEditor control's Text property: | ||
if (File.Exists(_fileName)) | ||
TextEditor.Text = File.ReadAllText(_fileName); | ||
} | ||
private void SaveButton_Clicked(object sender, EventArgs e) | ||
{ | ||
// Save the file. | ||
File.WriteAllText(_fileName, TextEditor.Text); | ||
} | ||
|
||
private void DeleteButton_Clicked(object sender, EventArgs e) | ||
{ | ||
// Delete the file. | ||
if (File.Exists(_fileName)) | ||
File.Delete(_fileName); | ||
|
||
TextEditor.Text = string.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters