In this article, we will continue with the interface that is created for Windows 8 application. This interface is used to create a not-taking application which is made using C#.

In this article, some real coding will be done by following various steps. In this, the user needs to double click on the button which is created in the interface. This double clicking is done to create the Click function for that button. As the button is clicked, the user needs to go back to the menu, but if the user is already in the menu then there is no need for this.

Going back to the main menu, will only close the Notepad but the note is not saved. When the new note is created, then the user wants this to be included in the NotesGrid. For this, we will be creating a new Textblock inside the memory and finally it is added to the NotedGrid so that it is appeared in it. This can also be done via the interface editor as explained in the article on creating the interface.

Now, when the new notes are created, a textblock which is created in the previous step will be shown under the button. If a lot of buttons are created, then they will be organized by themselves in a new column. Here, the important to be remembered is that the text is automatically cut off.

If the user wants to enable text wrapping, then the procedure is very simple. The only thing that is required to be done is to simply write block “TextWrapping = true;”

Figure 1: Shows the interface for the new note

After the notes are saved, the target is not completed yet. The user might need to edit the notes created again and again. So, in this case there will be need of separate Click function for every Textblock. The function will be same for every block and by writing it once, it can be assigned to each and every Textblock.

Listing 3: Shows the code for function to be assigned to every Textblock

private void SaveClose_Click(object sender, RoutedEventArgs e)
{
// If we are in text editing mode.
if (Notepad.Visibility == Visibility.Visible)
{
// Creates a new textblock that for this note.
TextBlock block = new TextBlock();
block.Width = 250;
block.Height = 125;
block.Text = Notepad.Text;
// Assign the click function.
block.Tapped += block_Tapped;
// Add that note to the grid.
NotesGrid.Items.Add(block);
// Go back to main menu.
Notepad.Visibility = Visibility.Collapsed;
NotesGrid.Visibility = Visibility.Visible;
}
}
private void block_Tapped(object sender, TappedRoutedEventArgs e)
{
// Get a reference to the block that has been tapped.
TextBlock block = sender as TextBlock;
// Open the text editor with the content of that block.
Notepad.Text = block.Text;
NotesGrid.Visibility = Visibility.Collapsed;
Notepad.Visibility = Visibility.Visible;
// Since we are currently editing this block, remove it from the menu.
// It will be added again once we save the note.
NotesGrid.Items.Remove(block);
}

Instead of deleting the notes, there can be a need to delete the notes. In order to do this, a new button will be added in the App Bar for it. But the App Bar can contain only one control at a time. For this, we have to add two or more button. But the problem is how it is done?

In order to it, we will place all the buttons inside a container and to do this, StickPanel will be used which is the most convenient option in this situation because it will be very easy to write it directly in the XAML editor.

To have full access to this post (or download the associated files) you must have MrBool Credits.

See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video.Subscribe for this package!