3 Replies - 942 Views - Last Post: 01 April 2013 - 06:56 AM Rate Topic: -----

#1 Rhaom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-March 13

[GUI] Custom Textbox Style?

Posted 31 March 2013 - 06:07 PM

Is it possible to add a background image to a textbox to make it look more stylized?
Is This A Good Question/Topic? 0
  • +

Replies To: [GUI] Custom Textbox Style?

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3622
  • View blog
  • Posts: 11,290
  • Joined: 05-May 12

Re: [GUI] Custom Textbox Style?

Posted 31 March 2013 - 06:52 PM

Yes, but it'll be easier to do in WPF vs. WinForms.
Was This Post Helpful? 0
  • +
  • -

#3 Rhaom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-March 13

Re: [GUI] Custom Textbox Style?

Posted 01 April 2013 - 03:57 AM

I am very new to C# and still at semi basic levels, I am assuming that "http://wpf.codeplex.com/" is what I am looking for?
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5582
  • View blog
  • Posts: 11,941
  • Joined: 02-June 10

Re: [GUI] Custom Textbox Style?

Posted 01 April 2013 - 06:56 AM

WPF is Windows Presentation Foundation.
You should be able to make a new WPF application from Visual Studio.
Its a different way of making your GUI. You use XAML and it will kinda feel like making a web page. But it is very powerful and lets you put any kind of element within another element. So you can put an image inside the background of a textbox.

I've been meaning to do a tutorials, but until then...


I don't like my tutorials to look like crap. So here is a sneak peek at something I hastily threw together so you have a sample. I'll clean it up on my days off to be a proper tutorial.

Make a new WPF project titled "WpfOneOhOne".
Now you can just copy/paste the code below to your MainWindows.XML replacing all the existing code.
Spoiler


Make a new UserControl called PersonData
Again just copy/replace all of the XAML with this
Spoiler


In the C# code-behind for the Mainwindow.xaml.cs, copy/replace with this code:
Spoiler


In the PersonData.xaml.cs, copy/replace all the code with this:
Spoiler


This will give you a very simple Windows with a very simple UserControl. Notice that as you type in the TextBox of the UserControl the TextBlock (yellow) of the MainWindow is updating in real time.

[attachment=32489:quickie.jpg]

The key points here is that nothing is directly accessing the .Text property of anything else.
Binding is used to related GUI controls to properties.
You can see how ElementName and Path relate to the instance of the UserControl and property of that instance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1