PDA

Click to See Complete Forum and Search --> : Making styles with VB Code...


vbman213
Jan 29th, 2009, 09:09 PM
So if you remember in old VB6 days, if you wanted to change the background color of a button you would just call

Command1.backgroundcolor = vbBlack

Now what I am wondering is if I modify a simple style button, make it look the way I want, is there a way to give my users a way of changing the colors (basically making a brush and applying it), etc...

jmcilhinney
Jan 29th, 2009, 09:16 PM
In WinForms it's much the same as in VB6, e.g.Button1.BackColor = Color.BlackIn WPF you would create a Brush and assign it to the Background property. If you just want a solid colour then you can use a SolidColorBrush, obtained from the Brushes class,e.g.Button1.Background = Brushes.BlackIf you want something fancier then you can create some other type of Brush.

jmcilhinney
Jan 29th, 2009, 09:27 PM
With regards to letting the user choose, you could either create a list of SolidColorBrush objects and display their Color properties for selection or, more likely, you would display a list of Colors and then create a new SolidColorBrush from the selected Color.

vbman213
Jan 29th, 2009, 10:23 PM
So like I have a control I've been working on and it has numerous parts to it... it is based off of the simple style combobox, but I've added and tweaked it so it looks how I want it... So how can I expose fill/brush properties for objects inside the control, instead of just the control itself...

jmcilhinney
Jan 29th, 2009, 10:36 PM
It's probably a good idea to actually ask the question you want answered to begin with, rather than working up to it.

As for the question itself, you pretty much answered it for yourself:So how can I expose fill/brush properties for objects inside the controlYou add a property to your parent control and you pass through the corresponding property of the child control. More than that I can't say without a more specific question.

Also, you should take into account that I've never used WPF myself, so there will be things that I'm not aware of. Others may have more information but all I've answered here came from reading the MSDN documentation after reading your question. That kinda makes me wonder, if I could look up the Button class and read about its Background property, etc., why others couldn't too.

vbman213
Jan 29th, 2009, 10:38 PM
Well these new questions are coming as I learn... I didn't have this question at the time of starting this thread... :/

Thanks for all the help btw