Click here to Skip to main content
Rate this: bad
good
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..
thanks
Window1.xaml
<window x:class="WpfApplication5.Window1" xmlns:x="#unknown">
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
    <grid>
        <listview name="ListView" itemssource="{Binding}">
            <listbox.contextmenu>
                <contextmenu name="cmclass" staysopen="true" datacontext="{Binding}">
                    <contextmenu.bitmapeffect>
 
                        <outerglowbitmapeffect />
 
                    </contextmenu.bitmapeffect>
 
                    <menuitem header="Assign Seperate Lesson" />
 
                    <menuitem header="exit" />
 

 
                </contextmenu>
            </listbox.contextmenu>
            <listview.view>
                <gridview>
                    <gridviewcolumn header="Position" displaymemberbinding="{Binding Position}" width="60">
                    </gridviewcolumn>
                    <gridviewcolumn header="Name" displaymemberbinding="{Binding Name}">
                        
                    </gridviewcolumn>
                    <gridviewcolumn header="status" displaymemberbinding="{Binding Status}">
                       
                    </gridviewcolumn>
                    <gridviewcolumn header="Ip Address" displaymemberbinding="{Binding IPAdd}" width="100">
 
                    </gridviewcolumn>
                </gridview>
            </listview.view>
        </listview>
    </grid>
</window>
 

 
Window.xaml.cs
<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()
        {
            InitializeComponent();
            ListView.DataContext = new ObservableCollection<Person>()
                            {
                                new Person() {Position = 1, Name ="abc", Status = "Online",IPAdd="198.168.1.2"},
                                new Person() {Position = 2, Name  = "xyz", Status = "Online",IPAdd="198.168.1.2"},
                                new Person() {Position = 3, Name= "lmn", Status = "Online",IPAdd="198.168.1.2"},
                                new Person() {Position= 4, Name = "pqr", Status = "Online",IPAdd="198.168.1.2"}
                            };
        }
        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
vishal_h1.7K
Edited 1-May-11 20:21pm
v3

1 solution

Rate this: bad
good
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?
  Permalink  
v2
Comments
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.1411023.1 | Last Updated 2 May 2011
Copyright © CodeProject, 1999-2014
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