I'm looking to apply styling to all WPF controls like what can be done with CSS in HTML.
This is my first dabbling in WPF and I've collected that I need to do this in App.xaml. Below is what I've got.
I've tried TargetType="{x:Type TabItem}" and TargetType="TabItem".
None of the styles I've defined are being applied.
App.xaml
<Application x:Class="VMware_Lab_Manager_Desktop.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary Source="Styles.xaml"></ResourceDictionary> </Application.Resources> </Application> Styles.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type TabControl}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF464646" Offset="0" /> <GradientStop Color="#FF2D2D2D" Offset="0.5" /> <GradientStop Color="#FF141414" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type TabItem}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF464646" Offset="0" /> <GradientStop Color="#FF2D2D2D" Offset="0.5" /> <GradientStop Color="#FF141414" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="BorderBrush"> <Setter.Value> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="#FF464646" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type Window}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> <GradientStop Color="#FF2D2D2D" Offset="0.5" /> <GradientStop Color="#FF141414" Offset="0" /> <GradientStop Color="#FF464646" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> </ResourceDictionary> MainWindow.xaml
<Window x:Class="VMware_Lab_Manager_Desktop.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="456" Width="803" Padding="0" Margin="0"> <TabControl HorizontalAlignment="Stretch" Margin="0" Padding="0" Name="tabControl1" VerticalAlignment="Stretch" BorderThickness="0" TabStripPlacement="Bottom"> <TabItem Name="tabItem1" Header="..."> <WebBrowser HorizontalAlignment="Stretch" Name="webBrowser1" Margin="0" VerticalAlignment="Stretch" Source="http://www.msdn.com/" /> </TabItem> <TabItem Header="+" /> </TabControl> </Window>
<ResourceDictionary Source="/VMware_Lab_Manager_Desktop;component/Themes/Style.xaml" />