question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataGrid: Could not resolve type DataGridCell

See original GitHub issue

I am using Avalonia and DataGrid (0.8.0). Including DataGrid theme into the application provokes the following error:

Error loading xaml at resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid: Could not convert object 'DataGridCell' (of type System.String) to {clr-namespace:Avalonia.Styling;assembly=Avalonia.Styling}Selector: Could not resolve type 'DataGridCell'

.csproj

    <ItemGroup>
        <PackageReference Include="Avalonia" Version="0.8.0" />
        <PackageReference Include="Avalonia.Controls.DataGrid" Version="0.8.0" />
    </ItemGroup>

App.xaml

<Application xmlns="https://github.com/avaloniaui">
    <Application.Styles>
        <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
        <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
        <StyleInclude Source="resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid" />
    </Application.Styles>
</Application>

The following workaround exists: execute some code to make sure Avalonia.Controls.DataGrid is loaded before using AvaloniaXamlLoader.

App.xaml.cs

public override void Initialize()
{
    var dataGridType = typeof(DataGrid); // HACK
    AvaloniaXamlLoader.Load(this);
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
grokyscommented, May 16, 2019

The UseDataGrid method is now no longer needed since #2322 so closing.

0reactions
ennerperezcommented, Oct 9, 2021

I am using Avalonia and DataGrid (0.8.0). Including DataGrid theme into the application provokes the following error:

Error loading xaml at resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid: Could not convert object 'DataGridCell' (of type System.String) to {clr-namespace:Avalonia.Styling;assembly=Avalonia.Styling}Selector: Could not resolve type 'DataGridCell'

.csproj

    <ItemGroup>
        <PackageReference Include="Avalonia" Version="0.8.0" />
        <PackageReference Include="Avalonia.Controls.DataGrid" Version="0.8.0" />
    </ItemGroup>

App.xaml

<Application xmlns="https://github.com/avaloniaui">
    <Application.Styles>
        <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
        <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
        <StyleInclude Source="resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid" />
    </Application.Styles>
</Application>

The following workaround exists: execute some code to make sure Avalonia.Controls.DataGrid is loaded before using AvaloniaXamlLoader.

App.xaml.cs

public override void Initialize()
{
    var dataGridType = typeof(DataGrid); // HACK
    AvaloniaXamlLoader.Load(this);
}

Also works with Avalonia.Svg.Skia.Svg for

XamlX.XamlParseException: Unable to resolve type SvgImage from namespace https://github.com/avaloniaui Line 17, position 16.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XAML Datagrid Cell Select style not working
I'm unable to get a datagrid cell select style to work under certain conditions. I have the following style:
Read more >
Mastering Windows Presentation Foundation: Build responsive ...
If the cell content is valid, we cast its Parent property value to its actual type of DataGridCell. If this DataGridCell object is...
Read more >
Pro WPF in VB 2010: Windows Presentation Foundation in .NET 4
Like an ordinary list control, the DataGrid lets the user select individual items. You can react to the SelectionChanged event when this happens....
Read more >
Pro WPF 4.5 in C#: Windows Presentation Foundation in .NET 4.5
To find out which data object is currently selected, you can use the ... When this property is true, users can't edit anything....
Read more >
How to make WPF DataGrid click Enter key to auto move ...
If cell "4" is last row, click Enter key to move to next row and next row does not exist, the DataGrid will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found