Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caliburn.Micro: Cannot close tab

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:

http://devlicio.us/blogs/rob_eisenberg/archive/2010/10/19/caliburn-micro-soup-to-nuts-part-6c-simple-mdi-with-screen-collections.aspx

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.

like image 917
David Shochet Avatar asked Jun 05 '26 08:06

David Shochet


1 Answers

Another way of doing it would be:

<Button Content="X" cal:Message.Attach="DeactivateItem($dataContext, 'true')" />

that way you don't have to create an extra method.

like image 180
gcores Avatar answered Jun 08 '26 00:06

gcores



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!