Saturday, December 31, 2016

Xamarin Android Multiline label not working properly

I was having an issue with getting a Label to multiline in an Xamarin forms ListView in an android app.

My XAML was this

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XamarinDev.BlogPage">
    <ListView ItemsSource="{Binding BlogPosts}" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout Padding="15,0" HorizontalOptions="Fill" VerticalOptions="StartAndExpand" >
                        <Label Text="{Binding Title}" FontAttributes="Bold" LineBreakMode="WordWrap"/>
                        <Label Text="{Binding Description}" LineBreakMode="WordWrap"></Label>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

And it looked like this



After I added HasUnevenRows="True" to the listview I got much better results

    <ListView ItemsSource="{Binding BlogPosts}" HasUnevenRows="True">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout Padding="15,0" HorizontalOptions="Fill" VerticalOptions="StartAndExpand" >
                        <Label Text="{Binding Title}" FontAttributes="Bold" LineBreakMode="WordWrap"/>
                        <Label Text="{Binding Description}" LineBreakMode="WordWrap"></Label>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>




Xamarin forms android emulator app not updating when debugging

I find that sometime when I am debugging a Xamarin Forms apps on a windows 10 machine the android apps do not show the latest updates in the emulator.  Typically when debugging on a windows 10 machine I do most of my debugging in the UWP app but when I switch to the hyper-V android emulator the app does not always show the latest changes.  To solve this I stop debugging the android version, go to the emulator and uninstall the app.  The next time you be debug you will see the latest version

Saturday, December 10, 2016

Fixing your Hyper-V emulators

If you are having problems getting your hyper-v emulators to run here are the steps I recommend to fix them

First and this usually fixes the issue.  Open the Hyper-V manager and delete all the virtual switches you will find them under the virtual switch manager



Try running the Hyper-V emulators again the switches will be recreated.  In the rare chance they still do not work go ahead and delete the virtual switches again. 



Now delete the virtual machines for the emulators.  Finally open the Device Manager and delete any hyper-v network adapters you might have




Rerun the emulators and they should work everything you deleted will be recreated.