![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | inherit controls in WPF Hi, I have a dialog with 2 TextBox controls. I want to add some functionality to one of the them. I created a class MyTextBox which inherits from TextBox. How can I connect one of the TextBox controls to my new class ? I tried to replace the line (created automatically) in "Window1.g.cs": internal System.Windows.Controls.TextBox YoavTextBox; with: internal MyTextBox YoavTextBox; but I get compilation errors. Yoav. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: inherit controls in WPF Hi, Yoavo wrote: Quote: > Hi, > I have a dialog with 2 TextBox controls. > I want to add some functionality to one of the them. > I created a class MyTextBox which inherits from TextBox. > How can I connect one of the TextBox controls to my new class ? > > I tried to replace the line (created automatically) in "Window1.g.cs": > internal System.Windows.Controls.TextBox YoavTextBox; > > with: > internal MyTextBox YoavTextBox; > > but I get compilation errors. > > Yoav. overwritten every time you build. If you have: namespace HelloWorld { public class MyTextBox : TextBox { // ... } } Then in your XAML code: <hello:MyTextBox Text="Hello world" xmlns:hello="clr-namespace:HelloWorld"/> You can also define the xmlns:hello part in the Window if you prefer. See also http://geekswithblogs.net/lbugnion/a...02/107747.aspx 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 Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Inherit from usercontrol - Object not set to instance of an object | .NET General | |||
| .NET Controls | .NET General | |||
| VS.NET and WPF controls | .NET General | |||