In my WPF Caliburn.Micro application, I have a TabControl. I want to be able to close tabs as needed. I found a way to do it here:
But when I try to apply it, I get an error:
No target found for method CloseItem.
Here is my code:
<TabControl x:Name="Items" >
<TabControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DisplayName}" />
<Button Content="X"
cal:Message.Attach="CloseItem($dataContext)" />
</StackPanel>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
Could you please help?
Thanks.
Not entirely certain what’s causing your exact issue (I suspect a very old tutorial coupled with a vastly different assembly is the issue) but I know how you can get it to work. Create any old public method like this and call it. It’s going to override what you’ve got in there so you could name it CloseItem. Then call this extension method and pass in the IConductor instance and the IScreen instance.