Exemple #1
0
        private void MenuGetHistoryUserDetails_Click(object sender, RoutedEventArgs e)
        {
            //Get the clicked MenuItem
            var menuItem = (MenuItem)sender;

            //Get the ContextMenu to which the menuItem belongs
            var contextMenu = (ContextMenu)menuItem.Parent;

            //Find the placementTarget
            var item = (DataGrid)contextMenu.PlacementTarget;

            //Get the underlying item, that you cast to your object that is bound
            //to the DataGrid (and has subject and state as property)
            var windowsUser = (RemoteLogonHistory)item.SelectedItem;

            if (windowsUser.LogonName.Length > 0)
            {
                string logonName;
                int    startIndex = windowsUser.LogonName.IndexOf(@"\", 0);
                logonName = windowsUser.LogonName.Substring(startIndex + 1);

                var wnd = new Dialog.UserDetailsWindow(logonName, windowsUser.LogonDomain);
                wnd.Show();
            }
        }
Exemple #2
0
        private void MenuGetUserDetails_Click(object sender, RoutedEventArgs e)
        {
            //Get the clicked MenuItem
            var menuItem = (MenuItem)sender;

            //Get the ContextMenu to which the menuItem belongs
            var contextMenu = (ContextMenu)menuItem.Parent;

            //Find the placementTarget
            var item = (DataGrid)contextMenu.PlacementTarget;

            //Get the underlying item, that you cast to your object that is bound
            //to the DataGrid (and has subject and state as property)
            var windowsUser = (RemoteLogonSession)item.SelectedItem;

            var wnd = new Dialog.UserDetailsWindow(windowsUser.Username, windowsUser.Domain);

            wnd.Show();
        }