private void RecentMenuItem_Click(object sender, RoutedEventArgs e) { var context = ((System.Windows.Controls.MenuItem)sender).DataContext as RecentFile; if (null != context) { fileName = context.Filepath; } }