Showing posts with label Universal Windows Platform. Show all posts
Showing posts with label Universal Windows Platform. Show all posts

Friday, May 4, 2018

UWP: How do you display a number entered as text as formated currency?

The entry you make in a text box control is of data type text and sometimes you need to format it as a currency with thousands separator while displaying.

Also, if the number of decimal places you enter is more than 2, you need to round it up to 2 in the output.

How do you code this in a UWP app?

Create a UWP page starting from a Blank UWP project with three controls as shown.





There are two text boxes and a button. You enter a number in the top textbox (txt1) and click the button, the formatted currency will be displayed in the bottom textbox(txt2).


The app displays as shown.

Now provide for a click event for the button and insert code as shown:

Convert_1

The string entered in txt1 is converted to data-type double, it is then 'rounded'. The rounded number is then formatted to show the currency symbol and the 1000's place delimiter you find, for example in Excel formatting.


Here is the app after entering a number and clicking the button.






Thursday, March 1, 2018

Universal Windows Application: What kind of data can be stored for UWP app?

There are basically two types:

  • App data
  • User Data


First of all App Data is different from User Data. App Data consists of data that is specific to a particular app. App data exists as long as the app active and removed when the app is removed.

App data includes:

  • Run time state
  • User preferences
  • Other settings


User data is a data created by the user for the application he has created. User data may be used by more than one app. This data may be manipulated by the user. User data is stored in user's libraries and Microsoft OneDrive.

What data types are in app data?

First of all these are the data types used in app settings:

  • UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double
  • Boolean
  • Char16, String
  • DateTime, TimeSpan
  • GUID, Point, Size, Rect
  • ApplicationDataCompositeValue


You can also use files to store binary data or to enbale cusomized serialized types.

Wednesday, February 28, 2018

How do you create a tabbed page control in Universal Windows Platform application?

Pivot control with its tabs helps you in navigating between items which can be content panes. Each item has a header to provide the text for the tab. The Pivot has a title and is the container of PivotItems.

The following 3 images show the navigation between three items.

In this app, the Pivot title is: Navigating with Pivot. The first PivotItem header is 'Home', the second PivotItem's header reads 'English' and the third PivotItem's header is 'Spanish'.

I have some text in English in the PivotItem with header 'English' and similarly a translation of the English text to Spanish in the PivotItem for Spanish. You can go from one page to the other easily. The images are from a deployment to a Lumia 950 phone.

Home is the first PivotItem in the app:

 Now navigated to English

Now navigated to the 'Spanish'


Now the code is very simple and uses only XAML statements

Here is the MainPage.xaml:

Note: Although this page does not throw an error. It builds, deploys and runs without an error but the Hyperlink in the first PivotItem is not active, although showing up as a hyperlink (underline and all!).
I am checking on this one. It is interesting to note that Hyperlink is not a control in the XAML tool set.

Monday, October 3, 2016

What is Windows Device family?

Windows evolved from just windows to include 'phones'.

When Windows 8.1 was introduced Windows Runtime(WinRT) which was evolution of Windows app model came up with the Universal Windows 8 apps for both Windows and Windows Phone. Windows and Windows Phone shared a ccommon piece of code.

Universal Windows Platform was introduced beginning Windows 10. The target was no more the Windows OS or Windows Phone OS but a common platform with a unified core. This core runs on all devices in the Windows family.

Devices running this core can target can not only call WinRT APIs that are common to all devices but also Win32 and .NET APIs that are specific to device family. This means all you need to develop is a single app package that can be installed on a wide variety of devices shown here.

UWP_00.PNG

On any device, you have therefore, the guaranteed core and you add APIs on top of it specific to the device. You will conditionally access the device specific features in your code.

Here is the present line up of the device family.

UWP_01.PNG

Here is a Video from Microsoft's Channel 9 with additional information:



Monday, October 12, 2015

What is Universal Windows Platform?

You will be hearing about this more and more as Windows 10 devices start appearing in increasing numbers that may reach billions.


Before Windows 10, the OS was Windows 8.1 and there were two devices
that were targeted by code:
  • Windows
  • Windows Phone
Developers created Universal Windows 8 apps using a shared codebase. For
this the Windows Runtime (WinRT), an evolution of the Windows app model
was introduced as a common application architecture.

With Windows 10 that has changed. Now there are a number of devices for
which you need to code has increased. Hence Universal Windows Platform
(UWP) was born.

WinRT gets evolved to be integrated with Windows 10 Core. This core
provides a common platform for every device that runs Window 10. UWP now
calls WinRT common for all the devices PLUS also APIs(Win32 and .NET)
that are specific to the device family the app runs on. Thus UWP
provides a guaranteed core API layer for all devices.

What it means is that your can be deployed to the device type you are
using. All devices use the same runtime but have their own unique API determined by the device type. The code access for those unique APIs specific to the device are conditional.

Note: Images are from Microsoft Site.