WINUI 3 Simple XAML Control Implementation from your How-to guide failts with XAML Parsing Er

Hi there, I installed the Nuget Syncfusion.Grid.WinUI 23.1.42, Visual Studio 22. On a brand spanking new page with no content/code except for the datagrid control i'm getting an XML Parsing Error (naturally being WinUI i cant delve into the error in detail). Even the Initialize SFGrid code in https://help.syncfusion.com/winui/datagrid/getting-started doesn't work and honestly, there is barely anything there. I can only assume something went wrong during the installation?


Every other datagrid i've tried works perfectly, this for some reason doesnt. Error: Microsoft.UI.Xaml.Markup.XamlParseException: 'XAML parsing failed.' Source: WinRT.Runtime, Stack Trace: 

   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)

   at ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.LoadComponent(IObjectReference _obj, Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)

   at CF_Dialog_01.Datagrids.Views.OrganizationPage.InitializeComponent() in C:\Users\Joshua.deWit\source\repos\Cloud-Frugality\CF-WINUI-MVP\CF-Dialog-01\CF-Dialog-01\obj\x64\Debug\net6.0-windows10.0.19041.0\Datagrids\Views\OrganizationPage.g.i.cs:line 41

   at CF_Dialog_01.Datagrids.Views.OrganizationPage..ctor() in C:\Users\Joshua.deWit\source\repos\Cloud-Frugality\CF-WINUI-MVP\CF-Dialog-01\CF-Dialog-01\Datagrids\Views\OrganizationPage.xaml.cs:line 24



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

<Page

    x:Class="CF_Dialog_01.Datagrids.Views.OrganizationPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:CF_Dialog_01.Datagrids.Views"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:dataGrid="using:Syncfusion.UI.Xaml.DataGrid"

    mc:Ignorable="d"

    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">


        <Grid x:Name="rootGrid2">

            <dataGrid:SfDataGrid x:Name="sfDataGrid" />

        </Grid>


</Page>



4 Replies

CM Chidanand Murugaiah Syncfusion Team October 26, 2023 02:12 PM UTC

Hi Joshua De wit,

 

Based on the provided information, we analyzed the reported scenario. When creating WINUI sample by default it creates the MainWindow.xaml and the contents are in between <Window></Window> tag. But Your code snippets are in between <Page></Page>. We have to create the BlankPage manually after creating the sample. Eventhough we add the controls in the BlankPage, need to call the BlankPage in the MainWindow. We are little bit unclear of the provided information, could you provide the following details

 

  • If possible, can you please replicate the reported scenario in the provided sample.
  • If possible, can you please provide the sample in which the reported scenario replicated.
  • Could you please check the reported scenario is only occurred when using syncfusion datagrid or any other syncfusion controls.

 

Providing these details will help us better understand the issue and work towards finding a solution promptly.

 

Regards,

Chidanand M.


Attachment: SfDataGrid_Net_10102392.zip


JD Joshua De wit October 27, 2023 05:24 AM UTC

Thanks Chidanand, your solution/sample works on my side. But interestingly enough, if i take the exact same code and lump it into my solution i get the same XAML parsing error. Instead of giving you my code, i created a new solution/project from scratch and created a virtually identical replica using the code you provided. I get the XAML parsing error there as well. So obviously something is going wrong during the WINUI project creation. 


Attachment: Reproduction_51ae7790.zip


CM Chidanand Murugaiah Syncfusion Team October 27, 2023 02:13 PM UTC

Hi Joshua De wit,


We are able to replicate the reported scenario in the provided sample. We need time to analyze the reported scenario and will provide an update on or before October 31, 2023.


Regards,

Chidanand M.



CM Chidanand Murugaiah Syncfusion Team October 31, 2023 11:31 AM UTC

Hi Joshua De wit,


Upon comparing the provided sample with our own, we noticed that the .cs project file contained different code snippets. After analyzing these code snippets, we recommend checking if the following package is installed in your Visual Studio. If it's not already installed, please add the package to your visual studio then create a new WINUI sample. This should resolve the 'XAML parsing failed' exception. This package is designed to simplify the creation of a single project with all the necessary dependencies.


Documentation Link - Package your app using single-project MSIX - Windows apps | Microsoft Learn

Download Link - Single-project MSIX Packaging Tools for VS 2022 - Visual Studio Marketplace


To resolve the exception, we modified .cs project of the provided sample and attached with this response.


Regards,

Chidanand M.


Attachment: Reproduction_5f889e38.zip

Loader.
Up arrow icon