This project is read-only.

How to create event for lisview itemclik?

Oct 8, 2012 at 6:51 AM

Hi Andy

I am using Okra framework in my app,I am able to show data in listview using this framework.But i want to use this framework for item click event, and based on paramater i will show another page.

I found one article on google they are creating behavoiurs,see below content

<ListView x:Name="lstModules"
      ItemsSource="{Binding Modules}">
      <interactivity:EventTrigger EventName="ItemClick">
          <julmar:InvokeCommand Command="{Binding SelectModule}" CommandParameter="{Binding ElementName=lstModules,Path=SelectedItem}" />
How i do that using okra framework?
Oct 8, 2012 at 12:51 PM


When using the Okra App Framework there are two approaches that I would suggest,

  • Firstly you could use one of the ports of the behaviours framework (such as and use this as above.
  • Alternatively (and the route I have been using in my own projects) you can add the 'ItemClick' event handler in the code-behind. Then you can cast the page's DataContext to your view-model type and call a method on the VM (passing in the clicked item). Not quite as neat a solution but works well.

Hope this helps,


Oct 8, 2012 at 8:45 PM

As an example, if you are clicking on a Photo in a list on your home page you would write the ItemClick event in the code behind as,

private void photoListView_ItemClick(object sender, ItemClickEventArgs e)
    if (DataContext is HomeViewModel)
        Photo photo = e.ClickedItem as Photo;
        HomeViewModel viewModel = (HomeViewModel)DataContext;