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.
Hi, Yoavo wrote: > 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. You must not modify the g.cs file. It is generated. Your changes will be 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/archive/2007/03/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