Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - WPF beginner question

 
 
Old 06-01-2007   #1 (permalink)
lallous


 
 

WPF beginner question

Hello

I am learning WPF, and created a <Button> element with a click event as:
<Button Click="doThis" Name="Button1"/>

Now my question should Orcas create the doThis() handler or I should
generated myself in the Page1.xaml.cs file?

Thanks,
Elias



My System SpecsSystem Spec
Old 06-10-2007   #2 (permalink)
David Cater


 
 

Re: WPF beginner question

I haven't played around with Orcas, but in VS2005 you have to create the
handler yourself.

It's an easy interface:

private void doThis (object sender, RoutedEventArgs e) {
...your code...
}

David Cater

"lallous" <lallous@lgwm.org> wrote in message
news:OtizdtJpHHA.4196@TK2MSFTNGP06.phx.gbl...
> Hello
>
> I am learning WPF, and created a <Button> element with a click event as:
> <Button Click="doThis" Name="Button1"/>
>
> Now my question should Orcas create the doThis() handler or I should
> generated myself in the Page1.xaml.cs file?
>
> Thanks,
> Elias
>


My System SpecsSystem Spec
Old 06-11-2007   #3 (permalink)
Laurent Bugnion, MVP


 
 

Re: WPF beginner question

Hi,

David Cater wrote:
> I haven't played around with Orcas, but in VS2005 you have to create the
> handler yourself.
>
> It's an easy interface:
>
> private void doThis (object sender, RoutedEventArgs e) {
> ...your code...
> }
>
> David Cater


If you're not sure about the arguments' types (it depends on the type of
event), the easiest is to write the (temporary) code as follows:

Button myButton = new Button();
myButton+=<TAB><TAB>;

where <TAB> is pressing the tab key. Visual Studio will create the event
signature for you. You can then remove the temporary code.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 06-11-2007   #4 (permalink)
David Cater


 
 

Re: WPF beginner question

LOL...I was thinking about suggesting that. I'm glad I'm not the only
person that does that...

D.

"Laurent Bugnion, MVP" <galasoft-lb@bluewin.ch> wrote in message
news:O6FWtrBrHHA.4548@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> David Cater wrote:
>> I haven't played around with Orcas, but in VS2005 you have to create the
>> handler yourself.
>>
>> It's an easy interface:
>>
>> private void doThis (object sender, RoutedEventArgs e) {
>> ...your code...
>> }
>>
>> David Cater

>
> If you're not sure about the arguments' types (it depends on the type of
> event), the easiest is to write the (temporary) code as follows:
>
> Button myButton = new Button();
> myButton+=<TAB><TAB>;
>
> where <TAB> is pressing the tab key. Visual Studio will create the event
> signature for you. You can then remove the temporary code.
>
> HTH,
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog: http://www.galasoft.ch
> PhotoAlbum: http://www.galasoft.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch


My System SpecsSystem Spec
Old 06-13-2007   #5 (permalink)
Laurent Bugnion, MVP


 
 

Re: WPF beginner question

Hi,

David Cater wrote:
> LOL...I was thinking about suggesting that. I'm glad I'm not the only
> person that does that...
>
> D.


:-) I am all about pragmatic programming... if it works and speeds up
writing code, it's good to me!

Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 06-14-2007   #6 (permalink)
lallous


 
 

Re: WPF beginner question

Hi Guys,

That is what I actually do.
Actually, you don't have to (re)define a Button from the code, cause
it is created when you define it in the XAML code.

But I was wondering if VS would also create the handler from me when I
say that a button has a Click handler (in the XAML code directly).

Regards,
Elias
On Jun 13, 11:40 pm, "Laurent Bugnion, MVP" <galasoft...@bluewin.ch>
wrote:
> Hi,
>
> David Cater wrote:
> > LOL...I was thinking about suggesting that. I'm glad I'm not the only
> > person that does that...

>
> > D.

>
> :-) I am all about pragmatic programming... if it works and speeds up
> writing code, it's good to me!
>
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog:http://www.galasoft.ch
> PhotoAlbum:http://www.galasoft.ch/pictures
> Support children in Calcutta:http://www.calcutta-espoir.ch



My System SpecsSystem Spec
Old 06-14-2007   #7 (permalink)
Laurent Bugnion, MVP


 
 

Re: WPF beginner question

Hi,

lallous wrote:
> Hi Guys,
>
> That is what I actually do.
> Actually, you don't have to (re)define a Button from the code, cause
> it is created when you define it in the XAML code.
>
> But I was wondering if VS would also create the handler from me when I
> say that a button has a Click handler (in the XAML code directly).
>
> Regards,
> Elias


In the current state, VS2005 cannot do this, no. WPF is an added
technology and the editor you use to type XAML is actually the XML
editor, with limited abilities.

I am not sure if VS2008 will allow this either (probably it will, since
Cider (the visual editor for XAML) will be better than in VS2005.

There is an alternative: Use Expression Blend:

- Open the project in Blend
- In the Project browser, right click on the solution and choose "Edit
in Visual Studio". This will start Visual Studio as your code editor.
- In Blend, select the control you want to add an event handler to.
Choose the "Properties" view on the right hand side, then select the
"Events" view (that's a small "lightning" button on the right top side
of Blend).
- Choose the event you want to handle, then double-click in the text
field next to the event.

This will switch to VS2005, and create the event handler for you. The
XAML code will also be updated to hook the event.

I recommend all my developers to have their projects open in Blend AND
VS2005 at the same time. It's a very nice way to work.

Good luck!
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 06-16-2007   #8 (permalink)
lallous


 
 

Re: WPF beginner question

Thank you for the tip Laurent.

So this is the right newsgroup to post my future WPF questions?

--
Elias
On Jun 14, 2:46 pm, "Laurent Bugnion, MVP" <galasoft...@bluewin.ch>
wrote:
> Hi,
>
> lallouswrote:
> > Hi Guys,

>
> > That is what I actually do.
> > Actually, you don't have to (re)define a Button from the code, cause
> > it is created when you define it in the XAML code.

>
> > But I was wondering if VS would also create the handler from me when I
> > say that a button has a Click handler (in the XAML code directly).

>
> > Regards,
> > Elias

>
> In the current state, VS2005 cannot do this, no. WPF is an added
> technology and the editor you use to type XAML is actually the XML
> editor, with limited abilities.
>
> I am not sure if VS2008 will allow this either (probably it will, since
> Cider (the visual editor for XAML) will be better than in VS2005.
>
> There is an alternative: Use Expression Blend:
>
> - Open the project in Blend
> - In the Project browser, right click on the solution and choose "Edit
> in Visual Studio". This will start Visual Studio as your code editor.
> - In Blend, select the control you want to add an event handler to.
> Choose the "Properties" view on the right hand side, then select the
> "Events" view (that's a small "lightning" button on the right top side
> of Blend).
> - Choose the event you want to handle, then double-click in the text
> field next to the event.
>
> This will switch to VS2005, and create the event handler for you. The
> XAML code will also be updated to hook the event.
>
> I recommend all my developers to have their projects open in Blend AND
> VS2005 at the same time. It's a very nice way to work.
>
> Good luck!
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog:http://www.galasoft.ch
> PhotoAlbum:http://www.galasoft.ch/pictures
> Support children in Calcutta:http://www.calcutta-espoir.ch



My System SpecsSystem Spec
Old 06-16-2007   #9 (permalink)
Laurent Bugnion, MVP


 
 

Re: WPF beginner question

Hi,

lallous wrote:
> Thank you for the tip Laurent.
>
> So this is the right newsgroup to post my future WPF questions?


Microsoft is trying to push users of WPF to rather post in MSDN:
http://forums.microsoft.com/MSDN/Sho...D=119&SiteID=1

This website has more traffic than the usenet group, and is monitored my
Microsoft.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 08-15-2007   #10 (permalink)
Mark Wilson-Thomas (MSFT)


 
 

Re: WPF beginner question

Good news - you no longer need to resort to tricks to get your event handlers
written for you. From Beta 2 of the Visual Studio 2008 product onwards, the
WPF designer (Cider) supports double clicking on the design surface to create
default handler, and XAML intellisense to create non-default ones.

You can get Beta 2 here
http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx

If you have feedback on the WPF Designer (aka Cider) in Visual Studio 2008
I'd encourage you to send it to the forum here:

http://forums.microsoft.com/msdn/def...d=169&siteid=1

Thanks

Mark Wilson-Thomas
Program Manager, WPF Designer Team, Visual Studio.

"Laurent Bugnion, MVP" wrote:

> Hi,
>
> lallous wrote:
> > Thank you for the tip Laurent.
> >
> > So this is the right newsgroup to post my future WPF questions?

>
> Microsoft is trying to push users of WPF to rather post in MSDN:
> http://forums.microsoft.com/MSDN/Sho...D=119&SiteID=1
>
> This website has more traffic than the usenet group, and is monitored my
> Microsoft.
>
> HTH,
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog: http://www.galasoft.ch
> PhotoAlbum: http://www.galasoft.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch
>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Beginner ASP Data Connection Question .NET General
VB.NET beginner Question .NET General
Question about WMI from a scripting beginner... PowerShell
General beginner question PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46