Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Is XamlCompile broken in latest Forms/VS??

$
0
0

Just so happens that today is first time trying out the XamlC feature. At first I tried the assembly level attribute in my App.cs file:

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

After compiling, I was getting a bunch of errors that were all identical. I also got a a different error on any page using a TemplateControl. So I pulled it off the assembly level and put a single class-level attribute on one page, and it still failed with the same error:

Value cannot be null.
Parameter name: method  

I poked around on Stackoverflow and found that about a year ago someone had the same issue (here), but they said they resolved it by upgrading Xam Forms to latest version. Since I'm on the latest stable versions, I have no where to go there.

I tried this class-level attribute on several pages in my app and only found it to work on a single page in my entire app... just so happens this page has zero bindings in the XAML markup. I'm wondering if a bug was introduced that causes it to blow up.

Markup of page that doesn't work:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Prepify.App.Pages.MainMenu"
                         xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
                         BackgroundColor="White"
             Title="Menu">
    <StackLayout VerticalOptions="FillAndExpand">
        <ListView
            Header="{Binding .}"
            SeparatorColor="{StaticResource dividerColor}"
            HasUnevenRows="True"
            ItemSelected="AppMenu_OnItemSelected"
            ItemTapped="AppMenu_OnItemTapped"
            ItemsSource="{Binding Items}"
            x:Name="appMenu">

            <ListView.HeaderTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition Width="10"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="80"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="5"/>
                        </Grid.RowDefinitions>

                        <BoxView Grid.ColumnSpan="4" Grid.RowSpan="4" BackgroundColor="{StaticResource grayDark}"/>
                        <controls:CircleImage Grid.Column="1" Grid.Row="1" HorizontalOptions="Start" VerticalOptions="End" Source="{Binding ProfileImageUrl}" WidthRequest="75" HeightRequest="75"/>
                        <Label Grid.Column="1" Grid.Row="2" Text="{Binding FullName}"/>
                        <ActivityIndicator Grid.Column="2" Grid.Row="2" IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" Color="White" WidthRequest="20" HeightRequest="20" VerticalOptions="Center" />

                    </Grid>
                </DataTemplate>
            </ListView.HeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal" >
                            <StackLayout.Padding>
                                <OnPlatform x:TypeArguments="Thickness" Android="15,15,15,15" iOS="25,12,15,12" />
                            </StackLayout.Padding>
                            <Image Source="{Binding Icon}" VerticalOptions="Center" WidthRequest="20" HeightRequest="20"/>
                            <Image WidthRequest="20"/>
                            <Label Text="{Binding Label}" VerticalOptions="Center" TextColor="{Binding LabelColor}" Style="{DynamicResource ListItemTextStyle}"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage>

Markup of only page that does work:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Prepify.App.Pages.Root"
    xmlns:pages="clr-namespace:Prepify.App.Pages;assembly=Prepify.App"
    MasterBehavior="Popover"
    Title="Make Preparedness Easy">

    <MasterDetailPage.Master>
        <pages:MainMenu/>
    </MasterDetailPage.Master>

</MasterDetailPage>

I'm using
Visual Studio 2015
Xamarin.Forms 2.3.3.193
Xamarin.VS 4.3.0.784


Viewing all articles
Browse latest Browse all 89864

Trending Articles