Emre Kadan
Emre Kadan

Reputation: 49

How to use a ListViewItem to navigate instead of a button? WPF, Caliburn Micro

I am using Caliburn.micro for navigation between views. When I use buttons to pass between views it works. But I would like to use ListView to navigate.

This is working;

 <Button x:Name="OpenOverview"/>

But this one is not working;

<ListViewItem
                   x:Name="OpenOverview"
                    Width="60"
                    Height="40"
                    Margin="0,5,0,0"
                    Padding="0"
                    HorizontalAlignment="Center"
                    HorizontalContentAlignment="Center"
                    RenderTransformOrigin="0.5,0.375"
                    ToolTipService.Placement="Right"
                    ToolTipService.ToolTip="Overview">

In my MainViewModel, I have ;

 public void OpenStorage()
    {
        ActivateItem(new StorageViewModel());
    }

How can I bind this to LİstView Item like I did for Button?

Upvotes: 0

Views: 74

Answers (1)

Anu Viswan
Anu Viswan

Reputation: 18155

I believe you want to Navigate depending on the selection in the ListView. You could do using Selected Event for the purpose.

<ListViewItem  cal:Message.Attach="[Event Selected]=[Action OpenOverview]">Overview Page</ListViewItem>

Please do remember to add following reference while using the cal:Message.Attach

xmlns:cal="http://www.caliburnproject.org"

Upvotes: 1

Related Questions