private void BtnBookmark_Click(object sender, RoutedEventArgs e) { try { Button btn = (Button)sender; if (btn.DataContext is BLL.HadithContentExt) { var temp = btn.DataContext as BLL.HadithContentExt; var item = new BLL.BookmarkExt() { HadithId = temp.HadithID, PageNo = temp.PageNo, ChapterNo = temp.ChapterNo, HadithNo = temp.HadithOrder }; if (item != null) { CallBookmarkEvent(item); } } } catch (Exception ex) { MessageBox.Show("Cannot add bookmark", "Info"); Logs.WriteLog("failed to add bookmark:" + ex.Message + " - " + ex.StackTrace); } }