tags:

views:

100

answers:

1

I'm looking for a textbox control(and or combo box) much like the IE or FireFox URL bar, as in i can pass it an image for the left side, and can get a styled combo box drop down instead of standards. And if there isnt, can i be informed on a good way to write the control myself?

+1  A: 

What you don't want to do is go about this the WinForms way and rewrite the control from scratch - this is actually very easy in WPF.

  1. Create a subclass of TextBox
  2. Add new DependencyProperties (Image for example)
  3. In Blend, click on an instance of your textbox and edit the default template.
  4. Group the PART_ContentHost into a Grid, then put your Image on the left side and TemplateBinding it to your new dependency properties
  5. Get rid of the style's name, so it'll apply to all instances of your subclassed Textbox.

It seems like a lot of steps, but really your subclassed codebehind will end up being very small, and editing the template gets right into the meat of what you're interested in, to change the look of a standard control.

Paul Betts
I'm in C# Express, so i'm without blend. That is something that is packaged with Visual Studio i believe. (sorry i forgot my password when i posted the question, but remembered it thereafter, so my nick is different)
Tommy
You can still do this in Visual Studio, you will just need to work directly in XAML rather than using the Blend visual editor. You will also need to create the template from scratch rather than using the default template as a starting point, but for a text box this shouldn't be a big loss!
itowlson
@itowlson: i could, other than the fact im quite the xaml novice, and wouldnt know where to start.
Tommy
@sniperX - there's a demo of Blend available online, I'd just grab that (or the "Blend for .NET 4 Preview"; just use it to grab out the default template for the Textbox and copy-paste it back to your project. Also just as a reminder, if you're using C# Express because you're a student, the DreamSpark program will get you all of this software for free!
Paul Betts
@Paul: Thanks so much for letting me in on DreamSpark, I'm going to take a serious look into that. Thanks!
Tommy