Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maui iOS Release Build throws XamlParseException #167

Open
vt-ombalakumar opened this issue Oct 6, 2023 · 5 comments
Open

Maui iOS Release Build throws XamlParseException #167

vt-ombalakumar opened this issue Oct 6, 2023 · 5 comments
Labels
awaiting-author Awaiting a respose from the author bug Something isn't working ios

Comments

@vt-ombalakumar
Copy link

Describe the bug
Showing normal XCalendar Events Calendar with navigation view as shown in the sample in my app's home page
I am trying to share the ios release build to testers, when opening the appication, app throws xaml parse exception

Issue Title
Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode)
Microsoft.Maui.Controls.Xaml.XamlParseException: Position 48:33. Cannot assign property "Property": Property does not exist, or is not assignable, or mismatching type between value and property

Stacktrace
Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode)
Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties)
Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties)
Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties)
Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType)
Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[CalendarView](CalendarView view, Type callingType)
XCalendar.Maui.Views.CalendarView.InitializeComponent()
XCalendar.Maui.Views.CalendarView..ctor()
WccMobileApp.Views.HomePage.InitializeComponent()
WccMobileApp.Views.HomePage..ctor()
WccMobileApp.MainPage.InitializeComponent()
WccMobileApp.MainPage..ctor()
WhiteCup.Views.LoginPage.OnLoginClicked(Object sender, EventArgs e)

Expected behavior
Events Calendar must be shown in the home page without any crash

Steps to reproduce OR link to code
This crash is not happening in debug mode
only happens when i try to build the app in the release mode

Xamarin Forms or .NET MAUI (If related to UI)
.NET MAUI
Additional context (Optional)

Device Info (Optional)
Device Model: iPhone SE (3rd Generation)
IOS Version: 16.3

@vt-ombalakumar vt-ombalakumar added the bug Something isn't working label Oct 6, 2023
@ME-MarvinE
Copy link
Owner

ME-MarvinE commented Oct 6, 2023

Could you provide a code snippet with your XAML?

@vt-ombalakumar
Copy link
Author

vt-ombalakumar commented Oct 6, 2023

yes sure
I have created 2 calendars

  1. events calendar
  2. connecting selected date calendar
    I am showing and hiding the calendar as per user selection of weekly / monthly calendar

`

                    <Border.StrokeShape>
                        <RoundRectangle CornerRadius="15"/>
                    </Border.StrokeShape>
                    <StackLayout>
                        <xc:CalendarView
            x:Name="MainCalendarView"
            LeftArrowCommand="{Binding NavigateCalendarCommand}"
            Days="{Binding EventCalendar.Days}"
            DaysOfWeek="{Binding EventCalendar.DayNamesOrder}"
            RightArrowCommand="{Binding NavigateCalendarCommand}"
            NavigatedDate="{Binding EventCalendar.NavigatedDate}"
            Style="{StaticResource DefaultCalendarViewStyle}">

                            <xc:CalendarView.RightArrowCommandParameter>
                                <x:Int32>1</x:Int32>
                            </xc:CalendarView.RightArrowCommandParameter>

                            <xc:CalendarView.LeftArrowCommandParameter>
                                <x:Int32>-1</x:Int32>
                            </xc:CalendarView.LeftArrowCommandParameter>

                            <xc:CalendarView.NavigationViewTemplate>
                                <ControlTemplate>
                                    <xc:NavigationView
                        ArrowColor="{StaticResource Primary}"
                        BackgroundColor="Transparent"
                        LeftArrowCommand="{Binding LeftArrowCommand, Source={RelativeSource TemplatedParent}}"
                        LeftArrowCommandParameter="{Binding LeftArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
                        RightArrowCommand="{Binding RightArrowCommand, Source={RelativeSource TemplatedParent}}"
                        RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
                        HeightRequest="30"
                        Text="{Binding Text, Source={RelativeSource TemplatedParent}}"
                        TextColor="{StaticResource Primary}"/>
                                </ControlTemplate>
                            </xc:CalendarView.NavigationViewTemplate>

                            <xc:CalendarView.DayTemplate>
                                <DataTemplate x:DataType="{x:Type Models:EventDay}">
                                    <Border Margin="2.5" BackgroundColor="Transparent" StrokeThickness="0">

                                        <Border.StrokeShape>
                                            <RoundRectangle CornerRadius="100" BackgroundColor="Transparent"/>
                                        </Border.StrokeShape>

                                        <xc:DayView
                            DateTime="{Binding DateTime}"
                            HeightRequest="24"
                            InvalidStyle="{StaticResource DefaultDayViewInvalidStyle}"
                            IsCurrentMonth="{Binding IsCurrentMonth}"
                            IsInvalid="{Binding IsInvalid}"
                            IsSelected="{Binding IsSelected}"
                            IsToday="{Binding IsToday}"
                            OtherMonthStyle="{StaticResource DefaultDayViewCurrentMonthStyle}">

                                            <xc:DayView.CurrentMonthStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewCurrentMonthStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.CurrentMonthStyle>

                                            <xc:DayView.TodayStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewTodayStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.TodayStyle>

                                            <xc:DayView.SelectedStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewSelectedStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.SelectedStyle>

                                            <xc:DayView.ControlTemplate>
                                                <ControlTemplate>
                                                    <!--  Using a Grid to stack views on the z axis  -->
                                                    <!--  TemplatedParent refers to the view that the ControlTemplate resides in  -->
                                                    <Grid BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}" RowSpacing="2">

                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="1.5*"/>
                                                            <RowDefinition Height="*"/>
                                                        </Grid.RowDefinitions>

                                                        <!--  ContentPresenter displays the default content for the control  -->
                                                        <ContentPresenter
                                            Grid.Row="0"
                                            Grid.RowSpan="2"
                                            VerticalOptions="Center"/>

                                                        <HorizontalStackLayout
                                            Grid.Row="1"
                                            BindableLayout.ItemsSource="{Binding Events}"
                                            HorizontalOptions="Center"
                                            Spacing="2.5">

                                                            <!--  I want the event indicators to only be visible when the DateTime is in the currently navigated month  -->
                                                            <HorizontalStackLayout.IsVisible>
                                                                <MultiBinding Converter="{StaticResource AllTrueConverter}">
                                                                    <Binding Path="IsCurrentMonth"/>
                                                                    <Binding Converter="{StaticResource InvertedBoolConverter}" Path="IsInvalid"/>
                                                                </MultiBinding>
                                                            </HorizontalStackLayout.IsVisible>

                                                            <BindableLayout.ItemTemplate>
                                                                <DataTemplate x:DataType="{x:Type Models:Event}">
                                                                    <BoxView
                                                        CornerRadius="100"
                                                        HeightRequest="7"
                                                        HorizontalOptions="CenterAndExpand"
                                                        VerticalOptions="Center"
                                                        WidthRequest="7"
                                                        Color="{Binding color}"/>
                                                                </DataTemplate>
                                                            </BindableLayout.ItemTemplate>
                                                        </HorizontalStackLayout>

                                                    </Grid>
                                                </ControlTemplate>
                                            </xc:DayView.ControlTemplate>

                                        </xc:DayView>
                                    </Border>
                                </DataTemplate>
                            </xc:CalendarView.DayTemplate>

                        </xc:CalendarView>
                        <VerticalStackLayout Spacing="0">
                            <VerticalStackLayout.Resources>
                                <Style
    x:Key="PropertyEditorContainer"
    CanCascade="True"
    TargetType="{x:Type Grid}">
                                    <Setter Property="Grid.ColumnDefinitions" Value="*,*"/>
                                    <Setter Property="HeightRequest" Value="50"/>
                                    <Setter Property="BackgroundColor" Value="{StaticResource Gray400}"/>
                                </Style>
                            </VerticalStackLayout.Resources>

                            <xc:CalendarView IsVisible="false" x:Name="WeekCalendarView"
                       LeftArrowCommand="{Binding NavigateCalendarCommand}"
                       Days="{Binding WeekCalendar.Days}"
                        DaysOfWeek="{Binding WeekCalendar.DayNamesOrder}"
                        RightArrowCommand="{Binding NavigateCalendarCommand}"
                        NavigatedDate="{Binding WeekCalendar.NavigatedDate}"
                        Style="{StaticResource DefaultCalendarViewStyle}"
                                >

                                <xc:CalendarView.RightArrowCommandParameter>
                                    <x:Int32>7</x:Int32>
                                </xc:CalendarView.RightArrowCommandParameter>

                                <xc:CalendarView.LeftArrowCommandParameter>
                                    <x:Int32>-7</x:Int32>
                                </xc:CalendarView.LeftArrowCommandParameter>

                                <xc:CalendarView.NavigationViewTemplate>
                                    <ControlTemplate>
                                        <xc:NavigationView
                                            ArrowColor="{StaticResource Primary}"
            BackgroundColor="Transparent"
            LeftArrowCommand="{Binding LeftArrowCommand, Source={RelativeSource TemplatedParent}}"
            LeftArrowCommandParameter="{Binding LeftArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
            RightArrowCommand="{Binding RightArrowCommand, Source={RelativeSource TemplatedParent}}"
            RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
                Style="{StaticResource DefaultNavigationViewStyle}"
            Text="{Binding Text, Source={RelativeSource TemplatedParent}}"
                                            TextColor="{StaticResource Primary}"/>
                                    </ControlTemplate>
                                </xc:CalendarView.NavigationViewTemplate>

                                <!--  Not Required, used only for styling.  -->
                                <xc:CalendarView.DayTemplate>
                                    <DataTemplate x:DataType="{x:Type Models:ConnectableDay}">
                                        <xc:DayView
            DateTime="{Binding DateTime}"
            HeightRequest="23"
            InvalidStyle="{StaticResource DefaultDayViewInvalidStyle}"
            IsCurrentMonth="{Binding IsCurrentMonth}"
            IsInvalid="{Binding IsInvalid}"
            IsSelected="{Binding IsSelected}"
            IsToday="{Binding IsToday}"
            OtherMonthStyle="{StaticResource DefaultDayViewCurrentMonthStyle}">    

                                            <xc:DayView.CurrentMonthStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewCurrentMonthStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.CurrentMonthStyle>

                                            <xc:DayView.TodayStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewTodayStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.TodayStyle>

                                            <xc:DayView.SelectedStyle>
                                                <Style BasedOn="{StaticResource DefaultDayViewSelectedStyle}" TargetType="{x:Type xc:DayView}">
                                                    <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/>
                                                    <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                                </Style>
                                            </xc:DayView.SelectedStyle>

                                            <!--
                The ControlTemplate should completely override the look of the control but this did not happen and the selected background color was still shown.
                Workaround was to set the Grid's colour to the normal background color and add an extra RoundRectangle for when nothing is connected.
            -->
                                            <xc:DayView.ControlTemplate>
                                                <ControlTemplate>
                                                    <Grid BackgroundColor="{StaticResource CalendarBackgroundColor}" BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}">

                                                        <!--  Workaround RoundRectangle  -->
                                                        <RoundRectangle
                            Margin="2.5"
                            CornerRadius="100"
                            Fill="{Binding BackgroundColor, Source={RelativeSource TemplatedParent}}"
                            StrokeThickness="0"/>

                                                        <RoundRectangle
                            Margin="0,2.5,2.5,2.5"
                            CornerRadius="0, 100, 0, 100"
                            Fill="{Binding BackgroundColor, Source={RelativeSource TemplatedParent}}"
                            IsVisible="{Binding ConnectsToLeft}"
                            StrokeThickness="0"/>
                                                        <RoundRectangle
                            Margin="2.5,2.5,0,2.5"
                            CornerRadius="100, 0, 100, 0"
                            Fill="{Binding BackgroundColor, Source={RelativeSource TemplatedParent}}"
                            IsVisible="{Binding ConnectsToRight}"
                            StrokeThickness="0"/>
                                                        <RoundRectangle
                            Margin="2.5,0,2.5,2.5"
                            CornerRadius="0, 0, 100, 100"
                            Fill="{Binding BackgroundColor, Source={RelativeSource TemplatedParent}}"
                            IsVisible="{Binding ConnectsToTop}"
                            StrokeThickness="0"/>
                                                        <RoundRectangle
                            Margin="2.5,2.5,2.5,0"
                            CornerRadius="100, 100, 0, 0"
                            Fill="{Binding BackgroundColor, Source={RelativeSource TemplatedParent}}"
                            IsVisible="{Binding ConnectsToBottom}"
                            StrokeThickness="0"/>

                                                        <ContentPresenter/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </xc:DayView.ControlTemplate>

                                        </xc:DayView>
                                    </DataTemplate>
                                </xc:CalendarView.DayTemplate>

                            </xc:CalendarView>
                        </VerticalStackLayout>
                    </StackLayout>
                </Border>`

@ME-MarvinE
Copy link
Owner

The error details that "Property" doesn't exist, or there is a mismatching type between what it expects, and the value given. The only place I found use of this is in the <setter> tags and I know those have "Property". So it must be the second part of the error which is mismatching type.

Where it says <Setter Property="Command" Value="{Binding BindingContext.ChangeDateSelectionCommand, Source={x:Reference This}}"/> double check that you have a property in your ViewModel called "ChangeDateSelectionCommand" and make sure it is of type "ICommand" or anything that inherits from it. Double check there is one control that has x:Name="This", typically the page and confirm that its BindingContext is your ViewModel. To confirm that this is causing the issue, remove the xc:DayView.OtherMonthStyle and see if it builds after that.

It may also be possible that in the line <Setter Property="BackgroundColor" Value="{StaticResource Gray400}"/>, it expects a SolidColorBrush rather than a Color. Similar to WPF. But this shouldn't be the issue.

Have you tried deleting parts of your XAML to identify where the error comes from?

It is useful to build projects in debug first so you get more detailed errors if they occur, then do a release build when you know everything should work. If you did already do this, did this issue come up only when you build in release mode?

@vt-ombalakumar
Copy link
Author

ok let me check the setter property lines

crash happens only when build the project in the release mode

@ME-MarvinE
Copy link
Owner

How about removing other parts of the XAML and building in release when testing it?

@ME-MarvinE ME-MarvinE added ios awaiting-author Awaiting a respose from the author labels Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Awaiting a respose from the author bug Something isn't working ios
Projects
None yet
Development

No branches or pull requests

2 participants