Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VS2008 C# WPF
i have added the context menu on list view and on click of view context i want to get the Ip address of student and on that ip add
i want to assign seperate lesson to only student of that machine plz help me.I just want how i get the IP address on which the context
menu occure and i am assigning lesson then i will using that ip send the message by using socket programming. i am posting my code here..
<window x:class="WpfApplication5.Window1" xmlns:x="#unknown">
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
        <listview name="ListView" itemssource="{Binding}">
                <contextmenu name="cmclass" staysopen="true" datacontext="{Binding}">
                        <outerglowbitmapeffect />
                    <menuitem header="Assign Seperate Lesson" />
                    <menuitem header="exit" />

                    <gridviewcolumn header="Position" displaymemberbinding="{Binding Position}" width="60">
                    <gridviewcolumn header="Name" displaymemberbinding="{Binding Name}">
                    <gridviewcolumn header="status" displaymemberbinding="{Binding Status}">
                    <gridviewcolumn header="Ip Address" displaymemberbinding="{Binding IPAdd}" width="100">

<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
namespace WpfApplication5
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
        public Window1()
            ListView.DataContext = new ObservableCollection<Person>()
                                new Person() {Position = 1, Name ="abc", Status = "Online",IPAdd=""},
                                new Person() {Position = 2, Name  = "xyz", Status = "Online",IPAdd=""},
                                new Person() {Position = 3, Name= "lmn", Status = "Online",IPAdd=""},
                                new Person() {Position= 4, Name = "pqr", Status = "Online",IPAdd=""}
        public class Person
            public int Position { get; set; }
            public string Name { get; set; }
            public string Status { get; set; }
            public string IPAdd { get; set; }
        private void Window_Loaded(object sender, RoutedEventArgs e)

Posted 30-Apr-11 3:52am
Edited 1-May-11 20:21pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your list view already displays the age in a column. So what would you achieve by that view menu?
vishal_h at 2-May-11 0:50am
thanks for prev response.sir i have change my question plz give your some inputs..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web02 | 2.8.150302.1 | Last Updated 2 May 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100