Category Archives: Styling

Si los PNGs te salen borrosos…

… incluso después de poner Stretch=”None”, debe ser que tienen una resolución distinta a la que usa el monitor! WPF los reescala de acuerdo a lo que se encuentra en pantalla. Quítales a todos los PNG la información de resolución con el PNGGauntlet!

Fresco: http://brh.numbera.com/software/pnggauntlet/

image

Después de todo, temporary failure!

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/23072c67-b024-4e62-b587-0e494b1d438a

Ahí queda la razón de mi retraso: no tengo ni idea de cómo transformar la idea en un Custom Control con sus Items y SubItems.

Todo esto es para la barra de herramientas. Me kagun! Al final no lo hice con las propiedades adjuntas que publiqué ayer.

Pues no, esto no fue la solución. Pero sí que lo hice finalmente con un Behavior (son la pera).

Si quieres ponerte súper duro haciendo ventanitas personalizadas

Con el WindowChrome vas a tener canela fina, pero pasarás un mal rato con sus particularidades y transparencias cacharreras. No olvides descargar el ensamblado Microsoft.Windows.Shell de aquí: http://archive.msdn.microsoft.com/WPFShell/Release/ProjectReleases.aspx?ReleaseId=4332

Aquí pongo una tandilla de estilos que harán las delicias de todos aquellos que quieran estilizar sus ventanas. Recomendable echarle un ojo a la más básica: DialogWindowStyle:

Generic.xaml

<ResourceDictionary

    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"

    xmlns:Shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"

    xmlns:Themes="clr-namespace:Filtro.Themes" mc:Ignorable="d">

 

    <SolidColorBrush x:Key="DialogBorderBrush" 

                         Color="DarkGray"/>

    <SolidColorBrush x:Key="DialogBackgroundBrush" 

                         Color="#FFEBEBEB"/>

    <SolidColorBrush x:Key="TitleTextBrush" 

            Color="White"/>

 

    <Style TargetType="{x:Type Themes:MaximizeButton}">

        <Setter Property="IsChecked" Value="True"/>

        <Setter Property="Width" Value="13"/>

        <Setter Property="Height" Value="13" />

        <Setter Property="Cursor" Value="Hand"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="{x:Type Themes:MaximizeButton}">

                    <Grid Margin="1" MinWidth="11.212" MinHeight="10.116" Width="11.212" Height="10.116" >

                        <VisualStateManager.VisualStateGroups>

                            <VisualStateGroup x:Name="CommonStates">

                                <VisualState x:Name="Normal"/>

                                <VisualState x:Name="Pressed">

                                    <Storyboard>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="border">

                                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>

                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="grid">

                                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>

                                        </DoubleAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="MouseOver"/>

                                <VisualState x:Name="Disabled"/>

                            </VisualStateGroup>

                            <VisualStateGroup x:Name="CheckStates">

                                <VisualState x:Name="Checked">

                                    <Storyboard>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grid">

                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>

                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">

                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>

                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Unchecked">

                                    <Storyboard>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grid">

                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>

                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">

                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>

                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Indeterminate"/>

                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="hitTest" BorderThickness="1" Background="Black" Opacity="0" IsHitTestVisible="True"/>

                        <Border x:Name="border" BorderBrush="White" BorderThickness="1.2,3,1.2,1.2" Margin="1" Visibility="Visible" SnapsToDevicePixels="True" d:IsHidden="True"  >

                            <Border.Effect>

                                <DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="1.5" Opacity="0"/>

                            </Border.Effect>

                        </Border>

                        <Grid x:Name="grid" Margin="1,0,1,1" Visibility="Collapsed" >

                            <Grid.Effect>

                                <DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="1.5" Opacity="0"/>

                            </Grid.Effect>

                            <Border x:Name="borderChecked02" BorderBrush="White" BorderThickness="0.8" Height="6" Width="6" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,0.5,0.5,0" SnapsToDevicePixels="True"/>

                            <Border x:Name="borderChecked01" BorderBrush="White" BorderThickness="1.2" Height="7" Width="7" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0" SnapsToDevicePixels="True"/>

                        </Grid>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style TargetType="{x:Type Themes:TitleCloseButton}">

        <Setter Property="Width" Value="13"/>

        <Setter Property="Height" Value="13" />

        <Setter Property="Cursor" Value="Hand"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="{x:Type Themes:TitleCloseButton}">

                    <Grid Margin="1" MinWidth="11.212" MinHeight="10.116" Width="11.212" Height="10.116" >

 

 

                        <VisualStateManager.VisualStateGroups>

                            <VisualStateGroup x:Name="CommonStates">

                                <VisualState x:Name="Normal"/>

                                <VisualState x:Name="MouseOver"/>

                                <VisualState x:Name="Pressed">

                                    <Storyboard>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="grid">

                                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>

                                        </DoubleAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Disabled"/>

                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>

 

 

                        <Border x:Name="hitTest" BorderThickness="1" Background="Black" Opacity="0" IsHitTestVisible="True"/>

                        <Grid x:Name="grid" Margin="0.57,0.574,0.566,0.567">

                            <Grid.Effect>

                                <DropShadowEffect BlurRadius="1.5" Opacity="0" Color="White" ShadowDepth="0"/>

                            </Grid.Effect>

                            <Path Data="M0.57104657,0.57617608 L9.6454003,8.5511275" Margin="0" Stretch="Fill" Stroke="White" StrokeThickness="2"/>

                            <Path Data="M0.59282188,8.5238779 L9.5987266,0.60561431" Margin="0.023,0.031,0.047,0.025" Stretch="Fill" Stroke="White" StrokeThickness="2"/>

                        </Grid>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>  

    

    <Style TargetType="{x:Type Themes:TitleMinimizeButton}">

        <Setter Property="Width" Value="13"/>

        <Setter Property="Height" Value="13" />

        <Setter Property="Cursor" Value="Hand"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="{x:Type Themes:TitleMinimizeButton}">

                    <Grid Margin="1" MinWidth="11.212" MinHeight="10.116" Width="11.212" Height="10.116" >

 

 

                        <VisualStateManager.VisualStateGroups>

                            <VisualStateGroup x:Name="CommonStates">

                                <VisualState x:Name="Normal"/>

                                <VisualState x:Name="MouseOver"/>

                                <VisualState x:Name="Pressed">

                                    <Storyboard>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="border">

                                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>

                                        </DoubleAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Disabled"/>

                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>

 

 

                        <Border x:Name="hitTest" BorderThickness="1" Background="Black" Opacity="0" IsHitTestVisible="True"/>

                        <Border x:Name="border" BorderBrush="White" BorderThickness="0,0,0,2" Margin="1" SnapsToDevicePixels="True"   >

                            <Border.Effect>

                                <DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="1.5" Opacity="0"/>

                            </Border.Effect>

                        </Border>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <SolidColorBrush x:Key="BorderWhiteBrush" Color="White"/>

    <SolidColorBrush x:Key="FillGgBlueBrush" Color="#FF389FD1"/>

 

    <Style x:Key="BlueWindowStyle" TargetType="Window">

        <Setter Property="Shell:WindowChrome.WindowChrome">

            <Setter.Value>

                <Shell:WindowChrome ResizeBorderThickness="6" CaptionHeight="10" CornerRadius="0" GlassFrameThickness="0"/>

            </Setter.Value>

        </Setter>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="Window">

                    <Grid>

                        <Border x:Name="mainBorder" BorderThickness="1" BorderBrush="{StaticResource BorderWhiteBrush}" Background="{StaticResource FillGgBlueBrush}">

                            <StackPanel Orientation="Horizontal">

                                <ContentPresenter  Margin="{Binding WindowNonClientFrameThickness, Source={x:Static Shell:SystemParameters2.Current}}"  Content="{TemplateBinding Content}"/>

                            </StackPanel>

                        </Border>

                        <StackPanel x:Name="mainStackPanel" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" >

                            <Themes:TitleMinimizeButton Height="20" Width="20" Margin="0" Shell:WindowChrome.IsHitTestVisibleInChrome="True" />

                            <Themes:MaximizeButton IsChecked="False" Height="20" Width="20" Margin="0" Shell:WindowChrome.IsHitTestVisibleInChrome="True" />

                            <Themes:TitleCloseButton Height="20" Width="20" Margin="0" Shell:WindowChrome.IsHitTestVisibleInChrome="True"/>

                        </StackPanel>

                        <StackPanel Margin="5,2,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">

                            <Image Source="{TemplateBinding Icon}" Width="16" Margin="0,0,5,0" />

                            <TextBlock x:Name="tBlock" Text="{TemplateBinding Title}" Foreground="White" FontWeight="Bold"  />

                            <StackPanel.Effect>

                                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="5" Opacity="0.5" />

                            </StackPanel.Effect>

                        </StackPanel>

                    </Grid>

                    <ControlTemplate.Triggers>

                        <Trigger Property="WindowState" Value="Maximized">

                            <Setter Property="Margin" TargetName="mainStackPanel" Value="0,5,10,0"/>

                            <Setter Property="Margin" TargetName="tBlock" Value="10,10,0,0"/>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style x:Key="DialogWindowStyle" TargetType="Window">

        <Setter Property="AllowsTransparency" Value="True" />

        <Setter Property="WindowStyle" Value="None" />

        <Setter Property="Shell:WindowChrome.WindowChrome">

            <Setter.Value>

                <Shell:WindowChrome ResizeBorderThickness="6" CaptionHeight="20" CornerRadius="10" GlassFrameThickness="0"/>

            </Setter.Value>

        </Setter>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="Window">

                    <DockPanel Opacity="1">

                        <Border x:Name="mainBorder" DockPanel.Dock="Top" CornerRadius="5,5,0,0">

                            <Border.Background>

                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                                    <GradientStop Color="#FF7C7C7C" Offset="0"/>

                                    <GradientStop Color="#FF4F4F4F" Offset="1"/>

                                </LinearGradientBrush>

                            </Border.Background>

                            <Grid x:Name="titleBarGrid">

                                <TextBlock VerticalAlignment="Center" Margin="0,4,0,4" FontSize="12"

                                                   FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" TextAlignment="Center"

                                                   Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" />

                                <Themes:TitleCloseButton HorizontalAlignment="Right" Height="16" Width="16" Margin="0,0,5,0" Shell:WindowChrome.IsHitTestVisibleInChrome="True"/>

                            </Grid>

 

                        </Border>

                        <Border Background="{DynamicResource DialogBackgroundBrush}" BorderBrush="{DynamicResource DialogBorderBrush}" BorderThickness="1,0,1,1" >

                            <ContentPresenter Content="{TemplateBinding Content}" Margin="15" />

                        </Border>

                    </DockPanel>

                    <ControlTemplate.Triggers>

                        <Trigger Property="WindowState" Value="Maximized">

                            <Setter Property="Margin" TargetName="titleBarGrid" Value="0,5,10,0"/>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style x:Key="GlossyButton" TargetType="Button">

        <Setter Property="Background" Value="#FF1F3B53"/>

        <Setter Property="Foreground" Value="#FF000000"/>

        <Setter Property="Padding" Value="3"/>

        <Setter Property="BorderThickness" Value="1"/>

        <Setter Property="BorderBrush">

            <Setter.Value>

                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                    <GradientStop Color="#FFA3AEB9" Offset="0"/>

                    <GradientStop Color="#FF8399A9" Offset="0.375"/>

                    <GradientStop Color="#FF718597" Offset="0.375"/>

                    <GradientStop Color="#FF617584" Offset="1"/>

                </LinearGradientBrush>

            </Setter.Value>

        </Setter>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="Button">

                    <Grid>

                        <VisualStateManager.VisualStateGroups>

                            <VisualStateGroup x:Name="CommonStates">

                                <VisualState x:Name="Normal"/>

                                <VisualState x:Name="MouseOver">

                                    <Storyboard>

                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">

                                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>

                                        </DoubleAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Pressed">

 

                                    <Storyboard>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="shine" Storyboard.TargetProperty="Opacity">

                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.4"/>

                                        </DoubleAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="glow" 

                                                Storyboard.TargetProperty="(UIElement.Visibility)">

                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">

                                                <DiscreteObjectKeyFrame.Value>

                                                    <Visibility>Collapsed</Visibility>

                                                </DiscreteObjectKeyFrame.Value>

                                            </DiscreteObjectKeyFrame>

                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>

                                </VisualState>

                                <VisualState x:Name="Disabled">

                                    <!-- <Storyboard>

                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">

                                                <SplineDoubleKeyFrame KeyTime="0" Value=".55"/>

                                            </DoubleAnimationUsingKeyFrames>

                                        </Storyboard> -->

                                </VisualState>

                            </VisualStateGroup>

                            <VisualStateGroup x:Name="FocusStates">

                                <VisualState x:Name="Focused">

                                    <!--<Storyboard>

                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">

                                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>

                                            </DoubleAnimationUsingKeyFrames>

                                        </Storyboard>-->

                                </VisualState>

                                <VisualState x:Name="Unfocused"/>

                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>

                        <Border BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">

                            <Border x:Name="border" Background="{x:Null}" BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">

                                <Grid>

                                    <Grid.RowDefinitions>

                                        <RowDefinition Height="0.507*"/>

                                        <RowDefinition Height="0.493*"/>

                                    </Grid.RowDefinitions>

                                    <Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4">

                                        <Border.Background>

                                            <RadialGradientBrush>

                                                <RadialGradientBrush.RelativeTransform>

                                                    <TransformGroup>

                                                        <ScaleTransform ScaleX="1.702" ScaleY="2.243"/>

                                                        <SkewTransform AngleX="0" AngleY="0"/>

                                                        <RotateTransform Angle="0"/>

                                                        <TranslateTransform X="-0.368" Y="-0.152"/>

                                                    </TransformGroup>

                                                </RadialGradientBrush.RelativeTransform>

                                                <GradientStop Color="#B28DBDFF" Offset="0"/>

                                                <GradientStop Color="#008DBDFF" Offset="1"/>

                                            </RadialGradientBrush>

                                        </Border.Background>

                                    </Border>

                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2"/>

                                    <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,0,0">

                                        <Border.Background>

                                            <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">

                                                <GradientStop Color="#99FFFFFF" Offset="0"/>

                                                <GradientStop Color="#33FFFFFF" Offset="1"/>

                                            </LinearGradientBrush>

                                        </Border.Background>

                                    </Border>

                                </Grid>

                            </Border>

                        </Border>

 

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

    <Style x:Key="GlossyDialogWindowStyle" TargetType="{x:Type Window}">

        <Setter Property="AllowsTransparency" Value="True" />

        <Setter Property="WindowStyle" Value="None" />

        <Setter Property="Shell:WindowChrome.WindowChrome">

            <Setter.Value>

                <Shell:WindowChrome ResizeBorderThickness="6" CaptionHeight="20" CornerRadius="10" GlassFrameThickness="0"/>

            </Setter.Value>

        </Setter>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="{x:Type Window}">

                    <DockPanel Opacity="1">

                        <Border x:Name="mainBorder" DockPanel.Dock="Top" CornerRadius="5,5,0,0">

                            <Grid x:Name="titleBarContainer" Background="#FF5A5A5A">

                                <Grid Margin="0">

                                    <Grid.RowDefinitions>

                                        <RowDefinition Height="0.507*"/>

                                        <RowDefinition Height="0.493*"/>

                                    </Grid.RowDefinitions>

                                    <Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4">

                                        <Border.Background>

                                            <RadialGradientBrush>

                                                <RadialGradientBrush.RelativeTransform>

                                                    <TransformGroup>

                                                        <ScaleTransform ScaleX="1.702" ScaleY="2.243"/>

                                                        <SkewTransform AngleX="0" AngleY="0"/>

                                                        <RotateTransform Angle="0"/>

                                                        <TranslateTransform X="-0.368" Y="-0.152"/>

                                                    </TransformGroup>

                                                </RadialGradientBrush.RelativeTransform>

                                                <GradientStop Color="#B28DBDFF" Offset="0"/>

                                                <GradientStop Color="#008DBDFF" Offset="1"/>

                                            </RadialGradientBrush>

                                        </Border.Background>

                                    </Border>

                                    <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,0,0">

                                        <Border.Background>

                                            <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">

                                                <GradientStop Color="#99FFFFFF" Offset="0"/>

                                                <GradientStop Color="#33FFFFFF" Offset="1"/>

                                            </LinearGradientBrush>

                                        </Border.Background>

                                    </Border>

                                </Grid>

                                <Grid x:Name="titleBarGrid" Margin="0,4,0,4">

                                    <TextBlock VerticalAlignment="Center"  FontSize="12"

                                            FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" TextAlignment="Center"

                                            Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}" />

                                    <Themes:TitleCloseButton HorizontalAlignment="Right" Height="16" Width="16" Margin="0,0,5,0" Shell:WindowChrome.IsHitTestVisibleInChrome="True"/>

                                </Grid>

                            </Grid>

 

                        </Border>

                        <Border Background="{TemplateBinding Background}" BorderBrush="{DynamicResource DialogBorderBrush}" BorderThickness="1,0,1,1" >

                            <ContentPresenter Content="{TemplateBinding Content}" Margin="15" />

                        </Border>

                    </DockPanel>

                    <ControlTemplate.Triggers>

                        <Trigger Property="WindowState" Value="Maximized">

                            <Setter Property="Margin" TargetName="titleBarGrid" Value="0,10,10,3"/>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

</ResourceDictionary>

MaximizeButton.cs

using System.Windows;

using System.Windows.Controls;

 

namespace Filtro.Themes

{

    public class MaximizeButton : CheckBox

    {

        static MaximizeButton()

        {

            DefaultStyleKeyProperty.OverrideMetadata(typeof(MaximizeButton), new FrameworkPropertyMetadata(typeof(MaximizeButton)));

        }

 

        private Window ParentWindow

        {

            get { return Window.GetWindow(this); }

        }

 

        public MaximizeButton()

        {

            Checked += (sObj, eArgs) =>

                           {

                               if (ParentWindow != null) ParentWindow.WindowState = WindowState.Maximized;

                           };

            Unchecked += (sObj, eArgs) =>

                             {

                                 if (ParentWindow != null) ParentWindow.WindowState = WindowState.Normal;

                             };

        }

    }

}

TitleCloseButton.cs

using System.Windows;

using System.Windows.Controls;

 

namespace Filtro.Themes

{

    public class TitleCloseButton : Button

    {

        static TitleCloseButton()

        {

            DefaultStyleKeyProperty.OverrideMetadata(typeof(TitleCloseButton), new FrameworkPropertyMetadata(typeof(TitleCloseButton)));

        }

 

        private Window ParentWindow

        {

            get { return Window.GetWindow(this); }

        }

 

        public TitleCloseButton()

        {

            Click += (sObj, eArgs) => { if (ParentWindow != null) ParentWindow.Close(); };

        }

 

    }

}

TitleMinimizeButton.cs

using System.Windows;

using System.Windows.Controls;

 

namespace Filtro.Themes

{

    public class TitleMinimizeButton : Button

    {

        static TitleMinimizeButton()

        {

            DefaultStyleKeyProperty.OverrideMetadata(typeof(TitleMinimizeButton), new FrameworkPropertyMetadata(typeof(TitleMinimizeButton)));

        }

 

        private Window ParentWindow

        {

            get { return Window.GetWindow(this); }

        }

 

        public TitleMinimizeButton()

        {

            Click += (sObj, eArgs) =>

                         {

                             if (ParentWindow != null) ParentWindow.WindowState = WindowState.Minimized;

                         };

        }

    }

}