Wintellect Blogs

Lighting up Native Platform Features in Xamarin Forms – Part 2

Keith Rome

20 May , 2015  

lighting-up-xf-feat

In the previous post I implemented a custom attached property to be used in Xamarin Forms XAML when a built-in accessory view is desired on a table cell. In this follow-up we will continue and build out the iOS renderer that is responsible for actually enabling the feature in our running application.

What about Android and Windows Phone – won’t they be affected too? That’s the beauty of the Xamarin Forms rendering model – it is up to each platform to decide how to natively implement the controls described in XAML markup. In this case, we have extended the existing XAML (not replaced it), and so the Android and Windows Phone renderers will simply just ignore the extensions unless we customize the renderers for those platforms as well.

Badge-Xamarin

TableView Rendering

Note: The following information comes through decompilation and inspection of the iOS renderers found in Xamarin.Forms.Platform.iOS (this assembly can be found in your Xamarin.iOS installation, or in your debug/bin output folder after compiling a Xamarin Forms project for iOS). I used JetBrains dotPeek to decompile the source from that assembly file.

The process of mapping a XAML TableView or ListView to a native UITableView/UITableViewSource and the various Xamarin Forms cell types to UITableViewCell objects is performed by a fairly complex orchestra of intertwined classes in the default iOS rendering system.… Read more

, ,

Wintellect Blogs

Lighting up Native Platform Features in Xamarin Forms – Part 1

Keith Rome

19 May , 2015  

lighting-up-xf-feat

In my last few posts I introduced a simple app that lets you browse the various built-in font variations supported by Xamarin Forms. If you recall, the application adopted a “stack navigation” design, which is quite common in mobile applications. However, there is one small flaw with our implementation so far – on the iOS platform it is customary to indicate that a ListView/TableView cell can be used to “drill down” into the navigation stack by including a “disclosure accessory” on the far right end of each cell. This accessory can be seen in the iOS Settings app below (the small chevron icons in the right margin of each cell):

image

Disclosure Indicators in the iOS System Settings App

Now, we could simply change our cell templates to add a custom image aligned to the right edge – but that wouldn’t be 100% correct. A Xamarin Forms TableView or ListView maps to the native UITableView, and if you review the iOS programming guide for Table Views you can see that there is built-in support for these that is provided by the operating system. These built-in icons can vary from one version of iOS to the next, and by using them (instead of custom icons) we can be assured that our application will continue to look correct as the platform evolves.… Read more

, , ,

Wintellect Blogs

Hey, Who Stole All My Memory?

Sergio Loscialo

16 May , 2015  

shutterstock_241808626

Sometimes a little piece of seemingly innocuous code can cause a significant amount of trouble:

public byte[] Serialize(object o)
{
    using (var stream = new MemoryStream())
    {
        MySerializer.Serialize(stream, o);
        return stream.ToArray();
    }
}

Doesn’t look like much, but I’m sure we have all written something like this and paid it no mind. In fact, most of the time, code like this isn’t a problem.

This little method becomes a problem when that object o parameter is larger than 85k (actually 84,988 bytes) in contiguous memory. At that point, this object is considered to be a “large object.” That designation is significant since when you’re done with an object like this, the .Net garbage collector stores it on the Large Object Heap (LOH) rather than in the gen 0 heap.

A situation called LOH fragmentation arises when applications are frequently creating and disposing many large objects. A classic example is a file upload service that receives and processes large volumes of data in each request. The resulting fragmentation can lead to an OutOfMemoryException being thrown, even if the server still has plenty of memory and there’s plenty of space left in the process address space.

So, getting back to our little innocuous piece of code: we already know that if o is a large object, it will consume space in the LOH.… Read more

,

Wintellect Blogs

Combining F# and Xamarin Forms to Create Mobile Applications

Jonathan Wood

14 May , 2015  

FSharpPCL

While we certainly have been busy getting our hands dirty with Xamarin I’ve been doing some of my own. However, I’ve been messing around with using Xamarin with F#. I mentioned in a previous post that F# can be used very well for enterprise applications. Here’s an in depth look at F# with Xamarin for mobile applications.

But why F# with Xamarin, you ask? Well, it just turns out that I love working with both of these technologies and I got lucky that the awesome folks at Xamarin and Dave Thomas – who does most of the great work with F# for Xamarin – decided to take on F# as a first class language.

Before we get started, it’s helpful to remember that, in F#, if you reference any other part of your code, whether it’s in the same file or not, the part you are referencing needs to be defined before you reference it. More info can be found at the wonderful F# for Fun and Profit site.

Currently in Xamarin (at the time of this writing – version 5.9) there aren’t any actual Xamarin Forms or PCL templates. Though, it is rumored there will be more templates in 6.0.… Read more

, ,

How To,Wintellect Blogs

Azure Bits #1 – Up and Running

Rik Robinson

12 May , 2015  

MicrosoftAzureBanner

Badge-Azure

 

As Steve Porter mentioned in his blog post, How Wintellect Uses Microsoft Azure, we are making pretty heavy use of many offerings in the Azure toolset for our internal and client-facing web properties here at Wintellect and have been doing so from the early days of Azure. As we continue to experiment with new and/or improved Azure offerings, I thought it might be helpful to share some of the more interesting things we’ve worked through as we explore that ever-increasing world that is Azure.

As the first sample application for these Azure Bits posts, I will create a small image manipulator example in Azure. This example will allow me to demonstrate several pieces of the Azure stack working together, including an Azure hosted web app, Azure Blob Storage, an Azure Queue, and an Azure hosted WebJob.

Azure Image Manipulator

For this first version of the Azure Image Manipulator, the user will only be able to browse and select an image from their computer and submit the image for processing. When the user submits the image, the original image will be inserted into Azure Blob Storage and a message will be placed in an Azure Queue indicating that a new image has been uploaded and needs to have a thumbnail created.… Read more

, ,

Wintellect Blogs

Spicing Up Universal Windows Apps with Per-Platform Views and Compiled Data Bindings

Jeff Prosise

6 May , 2015  

Since so many people make getting organized their New Year's resolution, your spice cabinet is a good place to start. Pictured from top, cinnamon, tandoori blend, dill, sweet Spanish paprika, fenugreek, cloves and curry, along with cardamom pods, fenugreek seeds, bay leaf and star anise. (Mark DuFrene/Contra Costa Times/MCT)

Adaptability is one of the hallmarks of the Universal Windows Platform (UWP). Apps that run on devices large and small must be able to adapt their UIs to the screen space available. UWP offers a number of tools for building adaptive UIs, including AdaptiveTrigger, RelativePanel, and controls that are cognizant of the screens they’re running on and willing to adapt themselves to provide the best user experience possible.

But sometimes the best way to optimize the experience on a particular device is to design the UI just for that device. I ran into that while porting Contoso Cookbook from Windows 8.1 to Windows 10. On a large screen, I wanted to use a GridView control to present rows and columns of recipes, starting in the upper-left corner and moving to the right, wrapping as needed to fill the screen with delicious recipes. On a phone, I envisioned a different experience built around a ListView control with a scrolling column of recipes.

Fortunately, UWP anticipates such scenarios and makes it rather easy to tailor UIs to individual devices – specifically, to device families: mobile devices, desktop devices, and so on. While doing the port, I also decided to leverage a new feature of Windows 10 that delivers faster performance and lower memory consumption.… Read more

,

Wintellect Blogs

Automating Analyzing Tons of Minidump Files with WinDBG and PowerShell

John Robbins

5 May , 2015  

NoDumping

When debugging a nasty problem in your code, one of the most helpful things you can get is a minidump. With that picture of what your app was doing at the time of the crash, hang, or when the memory started spiking, you’ve got a big hint to jumpstart your exploring. While there’s a bunch of tools out there, such as the wonderful ProcDump, and the debuggers themselves to create minidumps, the real moment of truth is when you have to look at those minidump. That’s easy to do with one or two, but what happens if you have 200? In my line of work, where I debug other’s software problems (and will be glad to help you with yours), I’m routinely faced with hundreds of dumps from a client. As much as I would like to carefully open each minidump and lovingly type the same commands over and over for the greatest consulting billing statement ever, I just can’t get my clients to pay for that.

What I really need is a way to say, “Here’s a bunch of .DMP files; go run these WinDBG commands across all of them.” It turns out that accomplishing that basic task is not hard at all when you combine a little WinDBG knowledge with a little PowerShell magic.… Read more

,

Wintellect Blogs

Using F# for Enterprise Applications

Jonathan Wood

5 May , 2015  

shutterstock_197284118

Though I have posted a few times on some of the awesome things F# can do for your code, that doesn’t necessarily mean it’s always good choice for each of your applications. You may look at the code features and and some sample code and think This is great, but I can’t see this being used other than in finance or data science projects. True, F# may be used fairly heavily in those areas, but I’d like to argue that it can be quite useful in enterprise applications, as well.

Lena, a fellow F# developer, has a very thought provoking article talking about F# in the enterprise especially when talking to decision makers at companies. I figured I’d expand on Lena’s post and offer my own thoughts to using F# in the enterprise.

The main thing about F#, that I’ve found, is that people often ask I like it, but where can I use it in my day-to-day development? Well, hopefully the below list will help out a lot and may even cause you to rethink what all F# can do for you.

Mobile Applications

Mobile applications are probably not exactly the first thing you’d think when you hear F#, is it?… Read more

,

Wintellect Blogs

API Convergence Gets Real in Windows 10

Jeff Prosise

4 May , 2015  

Picture-Me-Windows-Main-2.png

Last year, I wrote a universal app named Pic Me (later renamed to “Picture Me”) for Windows 8.1 and Windows Phone 8.1. The main reason I wrote it was that my daughter said “wouldn’t it be cool to have an app that shows you all the photos you’ve been tagged in on Facebook, and that lets you download those photos, too?” But the other reason I wrote it was that it seemed like a great opportunity to sink my teeth into a universal app for which there was a genuine need – not to mention the fact that it was a chance to use WebAuthenticationBroker and a handful of other WinRT classes that I hadn’t used much in the past.

Boy, was it an adventure. Because the app used WebAuthenticationBroker, FileSavePicker, and FolderPicker, and because the continuation model used by those classes was very different on Windows and Windows Phone, I ended up writing a fair amount of platform-specific code. Roughly one third of the code was shared, one third was Windows-specific, and one third was Windows Phone-specific. It was clear that the APIs were converging, but it was also clear that they had a long way to go if you wanted one binary to run on a variety of devices.… Read more

Wintellect Blogs

Wintellect.Analyzers for VS 2015 RC and Fixing Analyzer Install Problems with the Default Template Projects

John Robbins

4 May , 2015  

toolbox

Now that Visual Studio 2015 RC is fresh off the build machines and available for everyone, I’ve updated my Wintellect.Analyzers project (http://johnr.us/1bEO4h8) with full RC support. Go forth and add them to your project so you can get the benefit of advanced compiler analysis and code fixes. To add the analyzers, hit up your Package Manager Console with the following command:

  1. Install-Package Wintellect.Analyzers Prerelease

I guess you could go through the fancy new NuGet window in Visual Studio, but you want to be hard core and use PowerShell in VS!

If you’re interested in writing your own analyzers, as I have discussed previously, you’re immediately going to run into errors and warnings with projects based off the default Roslyn template when you try to install your analyzer masterpiece. Here’s what you’ll see:

Attempting to gather dependencies information for package ‘Analyzer1.1.0.0′ with respect to project targeting ‘.NETPortable, Version=v4.5, Profile=Profile7′
Attempting to resolve dependencies for package ‘Analyzer1.1.0.0′ with DependencyBehavior ‘Lowest’
Resolving actions to install package ‘Analyzer1.1.0.0′
Resolved actions to install package ‘Analyzer1.1.0.0′
Adding package ‘Analyzer1 1.0.0.0′ to folder ‘c:\junk\code\Analyzer1\packages’
Added package ‘Analyzer1 1.0.0.0′ to folder ‘c:\junk\code\Analyzer1\packages’
Added package ‘Analyzer1 1.0.0.0′ to ‘packages.config’
Executing script file ‘c:\junk\code\Analyzer1\packages\Analyzer1.1.0.0.0\tools\install.ps1′
Get-ChildItem : Cannot find path ‘C:\junk\code\Analyzer1\packages\Analyzer1.1.0.0.0\tools\analyzers\C#’ because it does not exist.Read more

,