Problem
When writing an Avalonia application, one might notice that some code is being executed before starting the application.
Cause
The behavior can be caused by the AvaloniaRider plugin. This plugin provides support for Avalonia development, including a screen layout preview. It partially executes the application to generate the layout of the screen.
Resolution
Avalonia has a Design.IsDesignMode property that can be used to determine if specific code should be executed in design/preview mode.
Usage example:
if (Design.IsDesignMode)
{
// code executed at design time
}
More information about design-time properties and data can be found in Avalonia documentation:
Comments
0 comments
Please sign in to leave a comment.