[Linux] No Fields from xaml in Code Behind

Hello Everyone,

when I add a UserControl to my Avalonia Project, the Code Behind is created alongside the axaml but I can not access the controls from the Code Behind (as described here: https://docs.avaloniaui.net/docs/fundamentals/code-behind).

I can, however, create an eventHandler automatically.

Let me give you an Example:

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="Todo.Helper.CustomControls.TestControl">
    
    <Button Name="greetingButton">Hello World</Button>
    
</UserControl>
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace Todo.Helper.CustomControls;

public partial class TestControl : UserControl
{
    public TestControl()
    {
        InitializeComponent();
        greetingButton.Content = "Goodbye Cruel World!";
    }
    
    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }
}

The greetingButton.Content is marked and I get the Error “Cannot resolve symbol ‘greetingButton’" and the application cannot be built.

Additionally I have to add the InitializeComponent() method manually, or the call gets marked. This has no effect on the application.

 

I use Bazzite and Rider has the Version 2026.2.1

 

Thank you in advance!

0
5 comments

Hello Tripple_U ,

Thank you for reaching Rider Forum.

On my Rider – Fedora install code-behind works as expected: 

Could you please share the following: 

  1.  Do you have the Avalonia plugin installed in Settings > Plugins? 
  2. If you do, could you please reproduce the issue and collect logs fro Help > Collect Logs and Diagnostic Data. Then upload them to https://uploads.jetbrains.com and provide the ID.
  3. Could you please provide a screenshot of how it is displayed on your side?
     
0

Thank you for your answer!

I do have the plugin installed.

Here is the screenshot. I hope it shows, what you need.

The UploadId is 2026_10_12_ZkHbyAWny3pu4RCBJqRTdM

0

Hello Tripple_U ,

Thank you for the update.

It isnot clearwhatis the source of the inconsistencies though. Could you please share the screen-shot of the Problems View Toolwindow? AI Self Review, Files and Tools/Environment tabs?

0

When I ran the AI Self-Review, it worked on it for over an hour, than I aborted it.
I created a new empty MVVM-Project, added a button like before and the AI Self-Review resulted in this:

I can not, however, mark the text, or do anything with this.

0

 Hello @Tripple_U,
Thank you for sharing details.
The warning  that you see Partial class with single part means that Rider does not see the part of DayControl that Avalonia generates. That part holds InitializeComponent() and the fields for named controls, so both stay unresolved.

 Unfortunately, it looks like you have faced a known issue: RIDER-135428: Partial class errors after creating a new Avalonia UserControl. Please upvote it to indicate your interest and subscribe to further status updates.
Could you please try the workaround from that issue?
 1. Select File | Invalidate Caches… and restart Rider.
 2. Build the project one time.
 Let me know if the errors remain after that.

 As for the AI Self-Review problem, it is not related to this one. The hang you saw is a known issue: LLM-29817: AI Self-Review: Review task hangs indefinitely in 2026.2 IDEs.

0

Please sign in to leave a comment.