private void sendPrivateMsg_onClick(object sender, RoutedEventArgs e) { MenuItem curMenu = sender as MenuItem; ContextMenu curContext = curMenu.Parent as ContextMenu; Point p = curContext.TranslatePoint(new Point(0, 0), FriendsTreeView); // 取父节点的父节点 DependencyObject obj = FriendsTreeView.InputHitTest(p) as DependencyObject; obj = VisualTreeHelper.GetParent(obj); obj = VisualTreeHelper.GetParent(obj); User curUser = ((ContentPresenter)obj).Content as User; User me = App.LoggedInUser; SendPrivateMsg spm = new SendPrivateMsg(curUser, me); spm.Show(); }
void mi_Click(object sender, RoutedEventArgs e) { //public static UserCollection followMeGroup = new UserCollection(); //public static UserCollection myFollowGroup = new UserCollection(); MenuItem m = sender as MenuItem; try { if (m.Name.Equals("viewTweet")) { SingleOneAllTweets soa = new SingleOneAllTweets(twitter, curItemRelated2ContextMenu.User); soa.Show(); } else if (m.Name.Equals("follow")) { twitter.ChangeFollowStatus(curItemRelated2ContextMenu.User.Id, "add"); myFollowGroup.Add(curItemRelated2ContextMenu.User); } else if (m.Name.Equals("unfollow")) { twitter.ChangeFollowStatus(curItemRelated2ContextMenu.User.Id, "delete"); myFollowGroup.Remove(curItemRelated2ContextMenu.User); } else if (m.Name.Equals("sendMsg")) { SendPrivateMsg spm = new SendPrivateMsg(curItemRelated2ContextMenu.User, App.LoggedInUser, twitter); spm.Show(); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }