Posts

Microsoft Windows Simulator is not working!

Image
The Simulator for testing apps is not working. It can be launched but you cannot exit. You may exit the development environment by closing Visual Studio but the simulator hangs around. Apps open in the simulator does not work, or work sporadically. Here are details of OS and the Visual Studio versions in which this was noted: Here is the abandoned Simulator: I will be upgrading to the next version of Visual Studio Community 2017 shown here:

Handling AppManifest Validation error

This error may show up if one chooses an image file that does not comply with the enumeration. Here is the description of the error: Severity Code Description Project File Line Suppression State Error  Validation error. error C00CE169: App manifest validation error: The app manifest must be valid as per schema: Line 26, Column 25, Reason: '' violates enumeration constraint of 'badge badgeAndTileText'. The attribute 'Notification' with value '' failed to parse. XXXXXX C:\Users\Owner\source\repos\xxxxxx\bin\ARM\Debug\AppxManifest.xml   I chose a resource for Badge in the Assets and Visual Studio spawned this error. The only way to get out of this was to comment out (or better remove) the following line in the AppManifest .xml Make sure you save the file after the removal as every time you Build, the AppManifest.xml gets recreated.

UWP: You can find the type of device you are deploying your UWP Project

Image
You can find this information using the Windows.System as shown here: Device_000 We can find the device to which the UWP is deployed using the above information. Here is a Blank UWP Project's MainPage.xaml. Device_0 I have a button and a text box. Button's click event finds the device information and writes to the text box using the click event shown here: Device_00 When deployed to the machine (Windows 10 Pro Desktop), the response is as shown. Device4.jpg When deployed to an emulator: The display shows the device info: You can get the DeviceFamilyVersion as well. The code is inside the image. On the emulator this is displayed.

UWP: Storing and retrieving composite application data

Image
You can store and retrieve composite application data in a UWP project using the Windows Storage. Specifically you will be using the Windows.Storage.ApplicationDataCompositeValue sealed class shown in the Object Browser. ObjBrowser.png In this post a project is described where in a pair of values are stored in the Windows Storage's local folder and retrieved. The values are stored using a button click event of a button and retrieved into text boxes in the click event of a second button. The MainPage.xaml for the project is as shown. MainPageXaml.png The code for storing and retrieving is shown in the MainPageXAMLCs. You first define the local settingss using the Windows.Storage.ApplicationDataContainer and the local folder . The composite values are set to the local settings. The retrieving is by extracting the values in the local settings and reading it into a text box. The result of running the application is shown here. The code can be simplified as...

UWP: Better use XAML's RichTextBlock than a TextBox for neat rendering of text?

Image
I wanted to disaply in my app a somewhat large amount of text contained in three paragaphs. Using a textbox with wrapping and scrolling did show all the text. However, as displayed text it was not satisfactory. Using 'paragraphs' inside 'RichTextBlock' provided the best option. The XAML code shows a TextBox and a RichTextBlock with three ' Paragraph ' controls. Both of them inside a ' ScrollViewer ' which makes it easy to scroll the text as shown. Here is the code for the MainPage.XAML This is the result rendered in the Local Machine. This one rendered to an emulator (4")

UWP: Displaying formatted text in a TextBox Control

Image
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 c...

UWP: Need to reduce the space between Pivot and PivotItem Header. Is there a way out?

Image
Real estate control is a common theme especially when it comes to devices such as smartphones with smaller display area. In my previous post , I did not take any particular care to adjust the space between Pivot and PivotItem Header. The display appears as shown. PivotSpace_0 I start with a Blank UWP app and add a Pivot Control as described (for example) here . Most of my posts start with a Blank Project. Now the displayed page appears as shown. In order to control the space (reduce it, essentially) you need to add a Page resource, the resource PivotHeaderItemMargin and reference it in your declration for the Pivot Items. Here is the resource I added for the page to control. PivotSpace_1 Now you need to declare the Margin for the two pivot items(on my page) as shown. Using appropriate value for 'Margin', you can control the space. Here are displays for various Margin settings. For the last item in red, a Margin was also added to the Pivot.  ...