Home > Mobile >  containing type does not implement interface 'IComponentConnector'
containing type does not implement interface 'IComponentConnector'

Time:12-16

IComponentConnector is implemented in the generated cs file

For some reason visual studio will not compile the below code.
I am on .NET 6 WPF.
Has there been any breaking changes that doesn't allow me to extend System.Windows.Window anymore ?
I am lost for words. The error makes no sense.
I'll post below my xaml and cs for the window:

<local:ExtendedWindow x:Class="Enciphered.Wpf.Window1"
                      x:TypeArguments="local:RoundedWindowViewModel"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      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"
                      xmlns:local="clr-namespace:Enciphered.Wpf"
                      mc:Ignorable="d"
                      Title="Window1" Height="450" Width="800">
    <Grid>

    </Grid>
</local:ExtendedWindow>
namespace Enciphered.Wpf
{
    public partial class Window1 : ExtendedWindow<RoundedWindowViewModel>
    {
        public Window1()
        {
            InitializeComponent();
        }
    }
}
using System.Windows;

namespace Enciphered.Wpf
{
    public class ExtendedWindow<TViewModel> : Window 
        where TViewModel: ViewModel
    {
        protected TViewModel? _viewModel;
        public TViewModel? ViewModel
        {
            get => _viewModel;
            set
            {
                if (_viewModel is not null)
                    if (_viewModel.Equals(value))
                        return;
                if (_viewModel is null && value is null)
                    return;
                _viewModel = value;
                DataContext = ViewModel;
            }
        }
    }
}

CodePudding user response:

Try to remove the following line from the project (.csproj) file and then build again:

<Nullable>enable</Nullable>
  • Related