as Simon Mourier Commented the solution was to add <UseWPF>true</UseWPF>
to .csproj
project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<UseWPF>true</UseWPF>
Was related to How can I reference WindowsBase in .Net5?