Before reading this article, please go through the following article.
- Introduction To Universal Windows Platform (UWP) App Development Using Windows 10 And Visual Studio 2015
Reading this article, you can learn how to apply Border resource to TextBlock Control in Universal Windows Apps development with XAML and Visual C#.
The following important tools are required for developing UWP,
- Windows 10 (Recommended)
- Visual Studio 2015 Community Edition (It is a free software available online)
Now, we can discuss steps of App development.
Step 1- Open Visual Studio 2015 -> Start -> New Project-> Select Universal (under Visual C#->Windows)-> Blank App -> Give a suitable name for your App (UWPBorderResource)->OK.
Step 2- Choose the Target and Minimum platform version your Universal Windows Application will support. Now, the project creates App.xaml and MainPage.xaml files.
Add TextBlock control and change the Name and Text property for title.
Step 3 - Add the following code for creating Local Resource for TextBlock. Then, add the TextBlock Control and set the text property as local resource string, named as Border.
- <Page.Resources>
- <x:String x:Key="Border">No Border</x:String>
- </Page.Resources>
Step 4 - Add border code and inside the border resource, use the same local resource string name (border string) and new content.
Add new Text Block Control, change name property, and remove the text content.
Step 5- Add the following code in the MainPage.xaml.cs constructor method,
- string s = (string)newborder.Resources["Border"];
- tblInborder.Text = s;
Step 6 - Deploy your app in Local Machine, and the output of the UWPBorderResource app.
Summary
Now, you have successfully created and applied Border Resource to TextBlock Control in Visual C# - UWP environment.