Skip to main content

Posts

Computer crashed (BSOD) after installing android emulators / virtual images

... had a rough few days after a recent BSOD. Fortunately I had a backup so I was able to restore to a consistent and healthy state (I hope). Unfortunately the BSOD was compounded by my Crucial M4 SSD "disappearing" after a hard shut down. Take a look here if you have a similar issue w/ your crucial SSD: http://www.extremetech.com/computing/169124-the-mysteriously-disappearing-drive-are-power-outages-killing-your-ssds
Also try to avoid hard shut downs.
Recent posts

Xamarin.Forms - start w/ both iOS and Android apps

I started w/ only iOS app development and and now realizing that it would've been easier to start the app development on both frameworks concurrently. I'm now reinstalling each nuget and making sure to install the same version, and trying to port iOS specific code to android. I just started so I'm hopeful it doesn't take more than a day (tomorrow).

Xamarin.Form's autosized label

Please see Sabon Rai Software's solution here: https://sabonrai.wordpress.com/2016/02/14/xamarin-forms-xaml-label-adjusts-font-size-to-fit-width-of-content/#comment-3002

In short, the AutosizeLabelRenderer code looks like this:


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21[assembly: ExportRenderer (typeof(AutosizeLabel), typeof(AutosizeLabelRenderer))]namespace<NAMESPACE>{publicclassAutosizeLabelRenderer:LabelRenderer{protectedoverridevoidOnElementChanged(ElementChangedEventArgs<Label>e){base.OnElementChanged(e);varlabel=ControlasUILabel;if(label!=null){label.AdjustsFontSizeToFitWidth=true;label.Lines=1;label.BaselineAdjustment=UIBaselineAdjustment.AlignCenters;//label.LineBreakMode = UILineBreakMode.Clip;label.MinimumScaleFactor=newSystem.nfloat(0.5);}}}}

Xamarin.Forms: making the switch control MVVM compliant

The switch control out of the Xamarin.Forms toolbox does not appear to be MVVM compliant. That means that its toggle (as a result of a UI tap) changes the state of the switch w/o validating or asking the Model (via the ViewModel) if it should change its state. I tried handling a "toggling" event or subclassing the switch but was unable to find a OOP solution to this problem. Instead I disabled the control and handled the ItemSelected event on the listView which first validates and then changes the state of the IsToggledProperty binding property. The disadvantage of incorrectly using the IsEnabled property is dimming an otherwise active control but at this point I'm able to live w/ this downside.

Microsoft's mobile center w/ xamarin.forms

Mobile center is a great and easy add-on to your xamarin.forms apps. It provides crash and usage analytics as well as push notifications and a distribution/testing framework. You just have to install a few nuget packages and add a few lines to start mobile center. One gotcha on the push notification component - it does not work in the iOS simulator. For those that got here from google and want to know why Push.IsEnabledAsync() returns false - note that you can not get notifications in the iOS simulator.

References:
https://mobile.azure.com
https://www.visualstudio.com/vs/mobile-center/

Let's talk about style...

Placeholder, will discuss:
global and implicit/explicit styles status bar and tabbed page colors (back/foreground)banded alternating rows Reference:
Xamarin styling: https://blog.xamarin.com/easy-app-theming-with-xamarin-forms-styles Microsoft colors: https://msdn.microsoft.com/en-us/library/aa358802(v=vs.85).aspx

Xamarin.Forms BindableProperty's unintuitive getter/setter properties

Apparently you cannot debug (or break into) these getter/setter properties of a BindableProperty and instead are advised to implement a propertyChanged event on the BindableProperty.
I made a userControl (as a refactored view w/in a view) and wanted to pass two bindable contexts to separate views w/in the parent view; something like this:


1 2<lv:MasterDetailArrableViewGrid.Row="1"Grid.Column="0"Grid.ColumnSpan="2"MasterArrable="{Binding FieldSelectionKeys}"DetailArrable="{Binding FieldSelectionFields}"/>
I decided to implement this by setting the internal view's BindingContext when the respective properties are set. However you cannot simply overwrite the MasterArrable setter and instead are advised to catch the propertyChanged event and do your work there. For example, the MasterArrable BindableProperty code looks like this:


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20publicstaticreadonlyBindablePropertyMasterAr…