This is a migrated thread and some comments may be shown as answers.

ListBoxItem doublecllick .. get MVVM

1 Answer 97 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 18 May 2012, 09:29 AM
Hi,

thank's for all xour help my listbox ist fine, but one more question. I have a EventSetter on my ListBoxItem

<EventSetter Event="MouseDoubleClick" Handler="ListBoxItem_MouseDoubleClick"/>

Code:
void ListBoxItem_MouseDoubleClick(object sender, RoutedEventArgs e)
{
    Frame pageFrame = null;
    pageFrame = helper.FindChild<Frame>(Application.Current.MainWindow, "MainFrame");
   
     if (pageFrame != null)
     {
         var content = pageFrame.Content as Page;
         var targetPage = content is Trichter1 ? new KontaktDetailAnsicht(myContact) as Page : new Trichter1() as Page;
          pageFrame.NavigateToExample(targetPage);
      }
 }

But how do i get the ViewModel? I tried Contact myContact = e.OriginalSource as Contact, but myContact is null? How do i get Values of my doubleclicked ListboxItem as my ViewModel?

Thanks
Regards
Rene

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 28 May 2012, 04:11 PM
Hello Rene,

You could get the DataContext of the RadListBoxItem using the sender parameter - you could cast it to RadListBoxItem and get the DataContext property.

Regards,
George
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ListBox
Asked by
ITA
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or