Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: Event Problem Pin
DaveyM6915-Mar-08 2:38
professionalDaveyM6915-Mar-08 2:38 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 3:00
Jammer15-Mar-08 3:00 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 2:39
Jammer15-Mar-08 2:39 
GeneralRe: Event Problem Pin
DaveyM6915-Mar-08 2:45
professionalDaveyM6915-Mar-08 2:45 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 3:05
Jammer15-Mar-08 3:05 
GeneralRe: Event Problem Pin
DaveyM6915-Mar-08 3:26
professionalDaveyM6915-Mar-08 3:26 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 3:41
Jammer15-Mar-08 3:41 
GeneralRe: Event Problem Pin
DaveyM6915-Mar-08 4:10
professionalDaveyM6915-Mar-08 4:10 
Done a very simple example that you may be able to learn from so you can fix your problem.

I created a default WPF app (WpfApplication1) then created a user control (UserControl1).
In UserControl1 (in the namespace but outside the class) I created a delegate
public delegate void UserControlDelegate(object sender, EventArgs e);
and (inside the class) an event public event UserControlDelegate UserControlEvent;
then added a public property that when set raises the event with this:
if (null != UserControlEvent)
      UserControlEvent(this, EventArgs.Empty);


Then I added this to Window1.xaml xmlns:UserControlNamespace="clr-namespace:WpfApplication1"
and then in the Grid block
<UserControlNamespace:UserControl1 x:Name="MyUsercontrol" Width="100" Height="100"></UserControlNamespace:UserControl1>
then changed the Window1 class in Window1.xaml.cs to
public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            MyUsercontrol.UserControlEvent += new UserControlDelegate(MyUsercontrol_UserControlEvent);
        }

        void MyUsercontrol_UserControlEvent(object sender, EventArgs e)
        {
            Console.WriteLine("Event Raised");
        }
    }


This is not exactly how I'd do it in production (I'd use protected virtual methods to raise the event etc, etc... ) but it should get you started.

Dave

GeneralRe: Event Problem Pin
Jammer15-Mar-08 5:06
Jammer15-Mar-08 5:06 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 5:15
Jammer15-Mar-08 5:15 
GeneralRe: Event Problem Pin
DaveyM6915-Mar-08 5:24
professionalDaveyM6915-Mar-08 5:24 
GeneralRe: Event Problem Pin
Luc Pattyn15-Mar-08 3:51
sitebuilderLuc Pattyn15-Mar-08 3:51 
GeneralRe: Event Problem Pin
Jammer15-Mar-08 4:00
Jammer15-Mar-08 4:00 
QuestionHow can I take data from a datagrid and display it in an Excel Spreadsheet? Pin
Walaza15-Mar-08 0:31
Walaza15-Mar-08 0:31 
AnswerRe: How can I take data from a datagrid and display it in an Excel Spreadsheet? Pin
buchstaben15-Mar-08 5:47
buchstaben15-Mar-08 5:47 
GeneralRe: How can I take data from a datagrid and display it in an Excel Spreadsheet? Pin
Walaza16-Mar-08 6:23
Walaza16-Mar-08 6:23 
GeneralRe: How can I take data from a datagrid and display it in an Excel Spreadsheet? Pin
buchstaben16-Mar-08 12:09
buchstaben16-Mar-08 12:09 
GeneralRe: How can I take data from a datagrid and display it in an Excel Spreadsheet? Pin
Walaza16-Mar-08 20:15
Walaza16-Mar-08 20:15 
GeneralDedect if right button is clicked in DataGridView column header Pin
AndrusM14-Mar-08 22:56
AndrusM14-Mar-08 22:56 
Questionwhat is best way to do this (create interaction between 2 application) ? Pin
Saeed.39414-Mar-08 22:12
Saeed.39414-Mar-08 22:12 
AnswerRe: what is best way to do this (create interaction between 2 application) ? Pin
Gareth H15-Mar-08 0:25
Gareth H15-Mar-08 0:25 
Generalpassing objects Pin
Miss Maheshwari14-Mar-08 22:12
Miss Maheshwari14-Mar-08 22:12 
GeneralRe: passing objects Pin
Colin Angus Mackay15-Mar-08 1:06
Colin Angus Mackay15-Mar-08 1:06 
QuestionUsin C# Code To Boot Into SafeMode? Pin
MadMan-2972914-Mar-08 21:48
MadMan-2972914-Mar-08 21:48 
AnswerRe: Usin C# Code To Boot Into SafeMode? Pin
Rajesh R Subramanian14-Mar-08 22:13
professionalRajesh R Subramanian14-Mar-08 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.