Forum Xamarin.Forms

Using Custom Style causing error: *An unhandled exception occured.*

HasanSyed.4377HasanSyed.4377 CAMember ✭✭
edited May 2018 in Xamarin.Forms

In App.xml, I've a custom style:

<?xml version="1.0" encoding="utf-8" ?>

<OnPlatform

            x:Key="GrialShapesFontFamily"
            x:TypeArguments="x:String"
            Android="grialshapes.ttf#grialshapes"
            iOS="grialshapes" />
 <Style
            x:Key="FontIconBase"
            TargetType="Label">
            <Setter
                Property="FontFamily"
                Value="{ StaticResource GrialShapesFontFamily }" />
        </Style>
        <!--Dashboard Item Template-->
        <Style
          x:Key="DashboardItemTemplateShape"
          TargetType="Label"
          BasedOn="{ StaticResource FontIconBase }">
            <Setter
              Property="Text"
              Value="{ x:Static local:GrialShapesFont.Circle }" />
            <Setter
              Property="FontSize">
                <Setter.Value>
                    <OnIdiom
                      x:TypeArguments="x:Double"
                      Phone="60"
                      Tablet="65" />
                </Setter.Value>
            </Setter>
            <Setter
              Property="Opacity"
              Value="1" />
        </Style>

I've used that style in below:

<?xml version="1.0" encoding="utf-8" ?>
<local:DashboardItemTemplateBase xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:artina="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared"
    xmlns:converter="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared.Base"
    xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
    xmlns:fftransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
    xmlns:local="clr-namespace:NswHealth"
  x:Class="NswHealth.DashboardItemTemplate"
  x:Name="Root">

            <StackLayout
              VerticalOptions="Center"
              HorizontalOptions="Center"
              Orientation="Vertical"
              Spacing="10">

                <Grid>

                    <Label
                      Style="{StaticResource DashboardItemTemplateShape}"
                      Text="BISMILLAH" />

                </Grid>
            </StackLayout> 

If I remove that Style="{StaticResource DashboardItemTemplateShape}" from the label, it works fine; but using that style throws an exception: An unhandled exception occured.

Any clue what's going wrong?

Sign In or Register to comment.