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

WPF

 
GeneralRe: XAML with a browser Pin
Pete O'Hanlon5-Apr-11 22:13
mvePete O'Hanlon5-Apr-11 22:13 
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 
[Update]

I got it. Here's my code:
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Name="Screen_1_Name"
	x:Class="WpfPrototype2Screens.Screen_1"
	Width="640" Height="480">

	<UserControl.Resources>
		<!--
		<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">              
			<ContentPresenter Content="{TemplateBinding Content}"/>         
		</ControlTemplate>     
 		-->
		
		<Style x:Key="ButtonFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2" SnapsToDevicePixels="true"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#F3F3F3" Offset="0"/>
			<GradientStop Color="#EBEBEB" Offset="0.5"/>
			<GradientStop Color="#DDDDDD" Offset="0.5"/>
			<GradientStop Color="#CDCDCD" Offset="1"/>
		</LinearGradientBrush>
		
		<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
		
		<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
			<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
			<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
			<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="HorizontalContentAlignment" Value="Center"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Padding" Value="1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" RenderDefaulted="{TemplateBinding IsDefaulted}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}">
							<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
						</Microsoft_Windows_Themes:ButtonChrome>
															
						<ControlTemplate.Triggers>
							<Trigger Property="IsKeyboardFocused" Value="true">
								<Setter Property="RenderDefaulted" TargetName="Chrome" Value="true"/>
							</Trigger>
							<Trigger Property="ToggleButton.IsChecked" Value="true">
								<Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="#ADADAD"/>
							</Trigger>
							
							<Trigger Property="IsMouseOver" Value="false">
								<Setter Property="Background" Value="Transparent"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Background="White">
		<Button Margin="241,142,279,163" 
				Style="{DynamicResource ButtonStyle1}" 
				BorderBrush="Transparent"
				Content="Button"/>
	</Grid>
</UserControl>


What did it was the Trigger and the transparent border brush on the button. When the mouse is NOT over the button, it's transparent. When the mouse is over it, the theme shows.

Coud you please elaborate on this:

<Microsoft_Windows_Themes:ButtonChrome ... > </Microsoft_Windows_Themes:ButtonChrome > tags and replace that with a Image and TextBlock.

Everything makes sense in someone's mind
modified on Monday, April 4, 2011 4:33 PM

GeneralRe: How To Style This Button [modified] Pin
SledgeHammer014-Apr-11 11:08
SledgeHammer014-Apr-11 11:08 
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 

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.