Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

WPF beginner question

Closed Thread
 
Thread Tools Display Modes
Old 06-01-2007   #1 (permalink)
lallous
Guest


 

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


Old 06-10-2007   #2 (permalink)
David Cater
Guest


 

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
>


Old 06-11-2007   #3 (permalink)
Laurent Bugnion, MVP
Guest


 

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
Old 06-11-2007   #4 (permalink)
David Cater
Guest


 

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


Old 06-13-2007   #5 (permalink)
Laurent Bugnion, MVP
Guest


 

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
Old 06-14-2007   #6 (permalink)
lallous
Guest


 

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



Old 06-14-2007   #7 (permalink)
Laurent Bugnion, MVP
Guest


 

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
Old 06-16-2007   #8 (permalink)
lallous
Guest


 

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



Old 06-16-2007   #9 (permalink)
Laurent Bugnion, MVP
Guest


 

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
Old 08-15-2007   #10 (permalink)
Mark Wilson-Thomas (MSFT)
Guest


 

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
>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner ASP Data Connection Question NC Beach Bum .NET General 0 07-12-2008 08:30 PM
VB.NET beginner Question a .NET General 4 06-29-2008 03:42 PM
Question about WMI from a scripting beginner... akcorr PowerShell 5 01-23-2008 12:25 PM
WPF: beginner question ... remember values in textbox Steve B. Avalon 2 08-03-2007 03:09 AM
General beginner question jering PowerShell 2 02-04-2007 01:54 PM








Vistax64.com 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 2005-2008

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 47 48 49 50