![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) |
| 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 > |
| | #3 (permalink) |
| 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 |
| | #4 (permalink) |
| 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 |
| | #5 (permalink) |
| 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 |
| | #6 (permalink) |
| 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 |
| | #7 (permalink) |
| 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 |
| | #8 (permalink) |
| 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 |
| | #9 (permalink) |
| 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 |
| | #10 (permalink) |
| 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 > |
| |
| |
![]() |
| 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 |