Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 9 Oct 2007 07:13:04 +0200,    group: microsoft.public.windows.developer.winfx.avalon        back       


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.
date: Tue, 9 Oct 2007 07:13:04 +0200   author:   Yoavo

Re: inherit controls in WPF   
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
date: Tue, 09 Oct 2007 17:59:01 +0200   author:   Laurent Bugnion, MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us