Step 1
Download Visual Studio Community 2015 and install it onto your computer, if it’s already downloaded and installed select Launch to start Visual Studio Community 2015 or if it has already been downloaded and installed then start the application you may also need to Enable your device for development.
Step 2
Once Visual Studio Community 2015 has started select File, then New, then Project… from the Menu.
Step 3
From the New Project window select Visual C# from Installed, Templates then select Blank App (Windows Universal) from the list, then type in a Name and select a Location to save to before selecting Ok to create the Project.
Step 4
Once done select from the Menu, Project, then Add New Item…
Step 5
From the Add New Item window select Visual C# from Installed then select Code File from the list, then type in the Name as Library.cs before selecting Add to add the file to the Project
Step 6
Once in the Code View for Library.cs the following should be entered:
using Windows.Storage; public class Library { public string LoadSetting(string key) { if (ApplicationData.Current.LocalSettings.Values[key] != null) { return ApplicationData.Current.LocalSettings.Values[key].ToString(); } else { return string.Empty; } } public void SaveSetting(string key, string value) { ApplicationData.Current.LocalSettings.Values[key] = value; } }
It should then appear as such:
Step 7
From the Solution Explorer select MainPage.xaml
Step 8
Select from the Menu, View then Designer
Step 9
The Design View will be displayed along with the XAML View and in this above <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:
<Page.BottomAppBar> <AppBar IsOpen="True" IsSticky="True"> <StackPanel Orientation="Horizontal"> <AppBarButton Name="New" Icon="Page" Label="New" Click="New_Click"/> <AppBarButton Name="Open" Icon="Folder" Label="Open" Click="Open_Click"/> <AppBarButton Name="Save" Icon="Save" Label="Save" Click="Save_Click"/> </StackPanel> </AppBar> </Page.BottomAppBar>
While still in the XAML View below <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”>enter the following XAML:
<StackPanel> <TextBox Name="Email" PlaceholderText="Email" InputScope="EmailSmtpAddress" Margin="20"/> <TextBox Name="Website" PlaceholderText="Website" InputScope="Url" Margin="20"/> <TextBox Name="Telephone" PlaceholderText="Telephone" InputScope="TelephoneNumber" Margin="20"/> </StackPanel>
It should appear as such:
Step 10
Select from the Menu, View then Code
Step 11
Once in the Code View below the public MainPage() { … } the following should be entered:
public Library Library = new Library(); private void New_Click(object sender, RoutedEventArgs e) { Email.Text = string.Empty; Website.Text = string.Empty; Telephone.Text = string.Empty; } private void Open_Click(object sender, RoutedEventArgs e) { Email.Text = Library.LoadSetting("Email"); Website.Text = Library.LoadSetting("Website"); Telephone.Text = Library.LoadSetting("Telephone"); } private void Save_Click(object sender, RoutedEventArgs e) { Library.SaveSetting("Email", Email.Text); Library.SaveSetting("Website", Website.Text); Library.SaveSetting("Telephone", Telephone.Text); }
It should then appear as such:
Step 12
That completes the Windows Universal Application so Save the Project then select the Debug and Simulator option to run the Application
Step 13
Once the Simulator has started the Application should then appear
Step 14
After the Application has started running you can then input some data such as an Email Address, Website and Telephone Number then store using the Save button and recall the data with the Open button
Step 15
To Exit the application select Stop Debugging in Visual Studio Community 2015
Step 16
Another option is to run as a Windows Phone application, select Debug and select Emulator 10.0.1.0 WVGA 4 inch 512MB option to run the Application
Step 17
Once the Emulator has started the Application should then appear
Step 18
After the Application has started running you can then input some data such as an Email Address, Website and Telephone Number then store using the Save button and recall the data with the Open button
Step 19
To Exit the application select Stop Debugging in Visual Studio Community 2015
Hi,
awesome tutorials and thank you for making them.
One thing. I was forced to use public static class and public static void in Library.cs file, because it was throwing me an error in MainPage.xaml.cs
Otherwise everything is working. Once again, thank you!
Petr
LikeLike
Thanks for the feedback I think I might have missed those “statics” off as it sounds right it should be using them
LikeLike
Great tutorials. I have some major feedback though. You never explain anything that you’re doing. You just say “Do this, do that. Code this” without explaining WHY you’re doing what you’re doing. You don’t even begin to explain what the XAML code represents or the classes you’re making!
These tutorials are extremely qualitative, and are becoming my de-facto standard of UWP tutorials. Because of that, it would be really appreciated if you upped your own ante of quality and assured that the content you share is up to par with the explanations for viewers to understand while they code. Other than that, fantastic job and keep it up!
LikeLike
Thanks for the feedback – it’s actually something I’ve been wanting to do, it takes a long time to put the tutorials together in their current form, but I’m planning to do exactly that and explain the steps in a longer format later – that will up the ante and then some, and go into more depth, am more keen to do this now I know how much it would be appreciated, thanks for the feedback!
LikeLike
the InputScope does not take effect
LikeLike
Thanks for letting me know, next year I’ll be releasing some new versions of this and other older Tutorials and will make sure this is working correctly in that
LikeLike