@Yoshi_Nastya

Как можно решить проблему Error: Object reference not set to an instance of an object XamlC?

Помогите, пожалуйста, ошибка в "нулевой строке"
Error: Object reference not set to an instance of an object XamlC

6026aa774798e590603201.png
Styles.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ResourceDictionary
    xmlns:graphics="clr-namespace:Syncfusion.XForms.Graphics;assembly=Syncfusion.Core.XForms"
    xmlns:converters="clr-namespace:NutritionDiary_app.Converters"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="NutritionDiary_app.AppLayout.Views.Styles">

    <converters:StringToImageResourceConverter x:Key="ImageResourceConverter" />

    <x:String x:Key="HomePageTitle">Nutrition Diary</x:String>

    <!--  Common style for action bar icons  -->
    <Style x:Key="ActionBarSettingIconStyle" TargetType="Button">
        <Setter Property="TextColor" Value="{DynamicResource Gray-White}" />
        <Setter Property="FontFamily" Value="{StaticResource FontIcons}" />
        <Setter Property="BackgroundColor" Value="Transparent" />
        <Setter Property="Text" Value="&#xe72b;" />
        <Setter Property="Padding" Value="{OnPlatform Default=8, UWP=6}" />
        <Setter Property="Margin" Value="4,8" />
        <Setter Property="HeightRequest" Value="{OnPlatform Default=32, UWP=40}" />
        <Setter Property="WidthRequest" Value="{OnPlatform Default=32, UWP=40}" />
    </Style>

    <!--  Common style for action bar labels  -->
    <Style x:Key="ActionBarLabelStyle" TargetType="Label">
        <Setter Property="TextColor" Value="{DynamicResource Gray-White}" />
        <Setter Property="FontFamily" Value="{StaticResource Montserrat-Regular}" />
        <Setter Property="FontSize" Value="16" />
    </Style>

    <!--  Common style for action bar back button  -->
    <Style x:Key="ActionBarBackButtonStyle" TargetType="Button">
        <Setter Property="TextColor" Value="{DynamicResource Gray-White}" />
        <Setter Property="FontFamily" Value="{StaticResource FontIcons}" />
        <Setter Property="Text" Value="&#xe709;" />
        <Setter Property="BackgroundColor" Value="Transparent" />
        <Setter Property="HorizontalOptions" Value="Start" />
        <Setter Property="HeightRequest" Value="34" />
        <Setter Property="WidthRequest" Value="34" />
        <Setter Property="Margin" Value="8" />
        <Setter Property="Padding" Value="8" />
    </Style>

    <!--  Common implicit style for ParallaxListView  -->
    <Style TargetType="controls:ParallaxListView">
        <Setter Property="BackgroundColor" Value="{DynamicResource Gray-White}" />
        <Setter Property="SeparatorVisibility" Value="None" />
        <Setter Property="VerticalScrollBarVisibility" Value="Never" />
    </Style>

    <!--  Common style for list view item title  -->
    <Style x:Key="ItemTitleStyle" TargetType="Label">
        <Setter Property="TextColor" Value="{DynamicResource Gray-900}" />
        <Setter Property="Text" Value="{Binding Name}" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="FontFamily" Value="{StaticResource Montserrat-SemiBold}" />
        <Setter Property="FontAttributes" Value="Bold" />
        <Setter Property="VerticalTextAlignment" Value="Center" />
        <Setter Property="VerticalOptions" Value="Center" />
    </Style>

    <!--  Common style for list view item description  -->
    <Style x:Key="ItemDescriptionStyle" TargetType="Label">
        <Setter Property="TextColor" Value="{DynamicResource Gray-700}" />
        <Setter Property="Text" Value="{Binding Description}" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="LineHeight" Value="1.25" />
        <Setter Property="VerticalTextAlignment" Value="Center" />
        <Setter Property="VerticalOptions" Value="Center" />
    </Style>

    <!--  Common style for list view item image  -->
    <Style x:Key="ItemImageStyle" TargetType="Image">
        <Setter Property="Source" Value="{Binding Icon, Converter={StaticResource ImageResourceConverter}}" />
        <Setter Property="HeightRequest" Value="80" />
        <Setter Property="WidthRequest" Value="80" />
        <Setter Property="VerticalOptions" Value="Center" />
    </Style>

    <!--  Common style for list view item template count  -->
    <Style x:Key="ItemCountLabelStyle" TargetType="Label">
        <Setter Property="TextColor" Value="{DynamicResource Gray-700}" />
        <Setter Property="Text" Value="{Binding TemplateCount}" />
        <Setter Property="FontFamily" Value="{StaticResource Montserrat-Regular}" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="VerticalTextAlignment" Value="Center" />
        <Setter Property="VerticalOptions" Value="Center" />
    </Style>

    <!--  Common style for content page  -->
    <Style x:Key="ContentPageStyle" TargetType="ContentPage">
        <Setter Property="NavigationPage.HasNavigationBar" Value="False" />
        <Setter Property="NavigationPage.HasBackButton" Value="False" />
        <Setter Property="Shell.NavBarIsVisible" Value="False" />
        <Setter Property="iOsSpecific:Page.UseSafeArea" Value="False" />
    </Style>

    <!--  Common style for close icons  -->
    <Style x:Key="CloseIconStyle" TargetType="Button">
        <Setter Property="TextColor" Value="{DynamicResource Gray-700}" />
        <Setter Property="FontFamily" Value="{StaticResource FontIcons}" />
        <Setter Property="BackgroundColor" Value="Transparent" />
        <Setter Property="Text" Value="&#xe724;" />
    </Style>

    <!--  Common style for header icon  -->
    <Style x:Key="HeaderIconStyle" TargetType="Image">
        <Setter Property="HorizontalOptions" Value="EndAndExpand" />
        <Setter Property="HeightRequest" Value="35" />
        <Setter Property="Margin" Value="0,0,8,0" />
        <Setter Property="Aspect" Value="AspectFit" />
        <Setter Property="Source" Value="HeaderIcon.png" />
    </Style>

    <!--  Common style for gradient buttons  -->
    <Style x:Key="SfGradientButtonStyle" TargetType="buttons:SfButton">
        <Setter Property="BackgroundGradient">
            <Setter.Value>
                <graphics:SfLinearGradientBrush>
                    <graphics:SfLinearGradientBrush.GradientStops>
                        <graphics:SfGradientStop Offset="0" Color="{DynamicResource PrimaryColor}" />
                        <graphics:SfGradientStop Offset="1" Color="{DynamicResource PrimaryGradient}" />
                    </graphics:SfLinearGradientBrush.GradientStops>
                </graphics:SfLinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="TextColor" Value="{DynamicResource Gray-White}" />
        <Setter Property="VerticalOptions" Value="FillAndExpand" />
    </Style>

</ResourceDictionary>

Styles.xaml.cs
using Xamarin.Forms.Internals;
using Xamarin.Forms.Xaml;

namespace NutritionDiary_app.Views.Forms
{
    /// <summary>
    /// Class helps to reduce repetitive markup, and allows an apps appearance to be more easily changed.
    /// </summary>
    [Preserve(AllMembers = true)]
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Styles
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Styles" /> class.
        /// </summary>
        public Styles()
        {
            InitializeComponent();
        }
    }
}
  • Вопрос задан
  • 22 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
НПК «Катрен» Новосибирск
от 90 000 ₽
WB—Tech Москва
от 140 000 до 160 000 ₽
Singularis Lab Волгоград
от 60 000 ₽
26 февр. 2021, в 05:09
3000 руб./за проект
26 февр. 2021, в 04:16
3000 руб./за проект
26 февр. 2021, в 01:40
1000 руб./за проект