Skip to content

Throws System.Reflection.TargetInvocationException while dragging a tab when the tabs are created using ItemsSource. #276

Description

@nima-ghomri

I have a .NET 7 WPF project where I defined a view and a view model as below:

MainWindow.xaml

<Window x:Class="DragablzExamples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DragablzExamples"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance Type=local:MainWindowViewModel}"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dragablz:TabablzControl ItemsSource="{Binding Items}" Margin="8">
            <dragablz:TabablzControl.InterTabController>
                <dragablz:InterTabController/>
            </dragablz:TabablzControl.InterTabController>
        </dragablz:TabablzControl>
    </Grid>
</Window>

MainWindow.xaml.cs

using System.Windows;

namespace DragablzExamples
{
    public class MainWindowViewModel
    {
        public string[] Items { get; set; } = new[] { "Item #1", "Item #2", "Item #3" };
    }
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            DataContext = new MainWindowViewModel();
            InitializeComponent();
        }
    }
}

When I try to drag a tab I get the System.Reflection.TargetInvocationException. It works perfectly when I add TabItems to the main container manually but it throws exception when I use binding. what is wrong with this simple view?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions