由于某种原因,Visual Studio不会编译以下代码。
我使用的是.NET 6 WPF。
是否有任何重大更改不允许我再扩展System.Windows.Window?
我无话可说。该错误没有任何意义。
我将在窗口下面发布我的 xaml 和 cs:
<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>
Run Code Online (Sandbox Code Playgroud)
namespace Enciphered.Wpf
{
    public partial class Window1 : ExtendedWindow<RoundedWindowViewModel>
    {
        public Window1()
        {
            InitializeComponent();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
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)) …Run Code Online (Sandbox Code Playgroud) 如何投射IEnumerable<IEnumerable<T>>a string[][]或a List<string[]>?
我已经尝试过了.toArray.SelectMany但他们似乎创造了string[]或者List<IEnumerable<string>>不是我真正想要的东西.