Click here to Skip to main content
15,904,415 members
Home / Discussions / WPF
   

WPF

 
QuestionHow To Style This Button Pin
Kevin Marois4-Apr-11 5:48
professionalKevin Marois4-Apr-11 5:48 
AnswerRe: How To Style This Button Pin
SledgeHammer014-Apr-11 6:43
SledgeHammer014-Apr-11 6:43 
GeneralRe: How To Style This Button Pin
Kevin Marois4-Apr-11 6:58
professionalKevin Marois4-Apr-11 6:58 
GeneralRe: How To Style This Button [modified] Pin
SledgeHammer014-Apr-11 7:08
SledgeHammer014-Apr-11 7:08 
GeneralRe: How To Style This Button Pin
SledgeHammer014-Apr-11 7:15
SledgeHammer014-Apr-11 7:15 
GeneralRe: How To Style This Button Pin
Kevin Marois4-Apr-11 7:18
professionalKevin Marois4-Apr-11 7:18 
GeneralRe: How To Style This Button [modified] Pin
Kevin Marois4-Apr-11 10:25
professionalKevin Marois4-Apr-11 10:25 
GeneralRe: How To Style This Button [modified] Pin
SledgeHammer014-Apr-11 11:08
SledgeHammer014-Apr-11 11:08 
You want it to look like the button in that screen shot right? So, you'll notice that the default state is just the text and the image, only the hover and pressed states show orange. Microsoft_Windows_Themes:ButtonChrome is a Microsoft class in PresentationFramework.Aero. Its responsible for drawing the Aero button. You'll notice Aero buttons have a lot of cross fade effects, glow effects, etc. You don't need that anymore for this type of button.

You might want to make a few adjustments...

1) You implemented this as a UserControl. What you probably want to do is implement this as a Control derived from Button. That will come into play later. For example, if you name your new control BackStageButton:

public class BackStageButton : Button
{
}

2) Now you should change your style declaration to:

// define a xmlns called local or whatever

<Style TargetType="{x:Type local:BackStageButton}">

this way you'll automatically style all BackStageButton instances instead of having to manually set the style.

3) get rid of all the RenderXXX setters (but leave the events) in your triggers, the RenderXXX setters will draw your button like Aero which is not what we want.

4) You probably want to structure your XAML something like this:

<Border name="BdOuter" Background="Transparent" CornerRadius="2,2"> <-- this will be the outside orange border
<Border name="BdInner" Background="Transparent" CornerRadius="2,2"> <-- this will be the white border
<Border name="BdFill" Background=Transparent" CornerRadius="2,2"> <-- this will be the orange gradient fill
<StackPanel Orientation="Vertical">
<Image Source="{Binding Whatever}" /> <-- you'll need to add a DP of type ImageSource so the user can specify the image
<TextBlock Text="{Binding Content}" /> <-- this will bind to the Button.Content property which is already there.

You'll need to screw around with the various RGB values and properties and so forth...

Then in your mouse over trigger, you would set BdOuter.Background -> Orange, BdInner.Background -> White and BdFill.Background to your GradientBrush static resource

and then do something similiar for the pressed state, just altering the RGB values to match.

Makes sense?



-- Modified Monday, April 4, 2011 5:16 PM
GeneralRe: How To Style This Button Pin
SledgeHammer014-Apr-11 11:12
SledgeHammer014-Apr-11 11:12 
AnswerRe: How To Style This Button Pin
Abhinav S4-Apr-11 21:13
Abhinav S4-Apr-11 21:13 
QuestionWebBrowser Control not displaying Pin
Grimes3-Apr-11 12:03
Grimes3-Apr-11 12:03 
AnswerRe: WebBrowser Control not displaying Pin
Grimes4-Apr-11 13:25
Grimes4-Apr-11 13:25 
QuestionHow to use ListView.SelectedItems in MVVM? Pin
SledgeHammer012-Apr-11 9:58
SledgeHammer012-Apr-11 9:58 
AnswerRe: How to use ListView.SelectedItems in MVVM? Pin
Mycroft Holmes2-Apr-11 12:48
professionalMycroft Holmes2-Apr-11 12:48 
AnswerRe: How to use ListView.SelectedItems in MVVM? Pin
Abhinav S3-Apr-11 6:29
Abhinav S3-Apr-11 6:29 
GeneralRe: How to use ListView.SelectedItems in MVVM? Pin
Kevin Marois4-Apr-11 9:55
professionalKevin Marois4-Apr-11 9:55 
GeneralRe: How to use ListView.SelectedItems in MVVM? Pin
SledgeHammer014-Apr-11 10:09
SledgeHammer014-Apr-11 10:09 
GeneralRe: How to use ListView.SelectedItems in MVVM? Pin
Kevin Marois4-Apr-11 10:26
professionalKevin Marois4-Apr-11 10:26 
GeneralRe: How to use ListView.SelectedItems in MVVM? Pin
Abhinav S4-Apr-11 21:12
Abhinav S4-Apr-11 21:12 
QuestionBing map control in a WPF application Pin
Jack_Sparow1-Apr-11 8:01
Jack_Sparow1-Apr-11 8:01 
AnswerRe: Bing map control in a WPF application Pin
Abhinav S1-Apr-11 20:53
Abhinav S1-Apr-11 20:53 
Question[C#, ListView] Conditional Formating of ListView<T> Items Pin
Dirk.Bock1-Apr-11 4:11
Dirk.Bock1-Apr-11 4:11 
AnswerRe: [C#, ListView] Conditional Formating of ListView Items Pin
BobJanova1-Apr-11 4:21
BobJanova1-Apr-11 4:21 
Questionnavigation Pin
arkiboys1-Apr-11 2:50
arkiboys1-Apr-11 2:50 
QuestionWPF Drag & Drop Pin
Kevin Marois31-Mar-11 5:58
professionalKevin Marois31-Mar-11 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.