4 changed files with 812 additions and 0 deletions
@ -0,0 +1,365 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public class ChildWindow : ContentControl |
|||
{ |
|||
#region Private Members
|
|||
|
|||
private TranslateTransform _moveTransform = new TranslateTransform(); |
|||
private bool _startupPositionInitialized; |
|||
private bool _isMouseCaptured; |
|||
private Point _clickPoint; |
|||
private Point _oldPosition; |
|||
private Border _dragWidget; |
|||
private FrameworkElement _parent; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static ChildWindow() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChildWindow), new FrameworkPropertyMetadata(typeof(ChildWindow))); |
|||
} |
|||
|
|||
public ChildWindow() |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
_dragWidget = (Border)GetTemplateChild("PART_DragWidget"); |
|||
if (_dragWidget != null) |
|||
{ |
|||
_dragWidget.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(HeaderLeftMouseButtonDown), true); |
|||
_dragWidget.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderMouseLeftButtonUp), true); |
|||
_dragWidget.MouseMove += (o, e) => HeaderMouseMove(e); |
|||
} |
|||
|
|||
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
|||
if (CloseButton != null) |
|||
CloseButton.Click += (o, e) => Close(); |
|||
|
|||
Overlay = GetTemplateChild("PART_Overlay") as Panel; |
|||
WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid; |
|||
|
|||
WindowRoot.RenderTransform = _moveTransform; |
|||
} |
|||
|
|||
protected override Size ArrangeOverride(Size arrangeBounds) |
|||
{ |
|||
_parent = VisualTreeHelper.GetParent(this) as FrameworkElement; |
|||
_parent.LayoutUpdated += (o, e) => |
|||
{ |
|||
//we only want to set the start position if this is the first time the control has bee initialized
|
|||
if (!_startupPositionInitialized) |
|||
{ |
|||
_startupPositionInitialized = true; |
|||
SetStartupPosition(); |
|||
} |
|||
}; |
|||
_parent.SizeChanged += (o, e) => |
|||
{ |
|||
Overlay.Height = e.NewSize.Height; |
|||
Overlay.Width = e.NewSize.Width; |
|||
}; |
|||
|
|||
return base.ArrangeOverride(arrangeBounds); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Properties
|
|||
|
|||
#region Internal Properties
|
|||
|
|||
internal Panel Overlay { get; private set; } |
|||
internal Grid WindowRoot { get; private set; } |
|||
internal Thumb DragWidget { get; private set; } |
|||
internal Button MinimizeButton { get; private set; } |
|||
internal Button MaximizeButton { get; private set; } |
|||
internal Button CloseButton { get; private set; } |
|||
|
|||
#endregion //Internal Properties
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(ChildWindow), new UIPropertyMetadata(String.Empty)); |
|||
public string Caption |
|||
{ |
|||
get { return (string)GetValue(CaptionProperty); } |
|||
set { SetValue(CaptionProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(ChildWindow), new UIPropertyMetadata(null)); |
|||
public Brush CaptionForeground |
|||
{ |
|||
get { return (Brush)GetValue(CaptionForegroundProperty); } |
|||
set { SetValue(CaptionForegroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Style CloseButtonStyle |
|||
{ |
|||
get { return (Style)GetValue(CloseButtonStyleProperty); } |
|||
set { SetValue(CloseButtonStyleProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CloseButtonVisibilityProperty = DependencyProperty.Register("CloseButtonVisibility", typeof(Visibility), typeof(ChildWindow), new PropertyMetadata(Visibility.Visible)); |
|||
public Visibility CloseButtonVisibility |
|||
{ |
|||
get { return (Visibility)GetValue(CloseButtonVisibilityProperty); } |
|||
set { SetValue(CloseButtonVisibilityProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register("Icon", typeof(ImageSource), typeof(ChildWindow), new UIPropertyMetadata(default(ImageSource))); |
|||
public ImageSource Icon |
|||
{ |
|||
get { return (ImageSource)GetValue(IconSourceProperty); } |
|||
set { SetValue(IconSourceProperty, value); } |
|||
} |
|||
|
|||
#region Left
|
|||
|
|||
public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnLeftPropertyChanged))); |
|||
public double Left |
|||
{ |
|||
get { return (double)GetValue(LeftProperty); } |
|||
set { SetValue(LeftProperty, value); } |
|||
} |
|||
|
|||
private static void OnLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow dialog = (ChildWindow)obj; |
|||
dialog.Left = dialog.GetRestrictedLeft(); |
|||
dialog.ProcessMove((double)e.NewValue - (double)e.OldValue, 0); |
|||
} |
|||
|
|||
#endregion //Left
|
|||
|
|||
#region OverlayBrush
|
|||
|
|||
public static readonly DependencyProperty OverlayBrushProperty = DependencyProperty.Register("OverlayBrush", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(OnOverlayBrushPropertyChanged)); |
|||
public Brush OverlayBrush |
|||
{ |
|||
get { return (Brush)GetValue(OverlayBrushProperty); } |
|||
set { SetValue(OverlayBrushProperty, value); } |
|||
} |
|||
|
|||
private static void OnOverlayBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow cw = (ChildWindow)d; |
|||
|
|||
if (cw.Overlay != null) |
|||
{ |
|||
cw.Overlay.Background = (Brush)e.NewValue; |
|||
} |
|||
} |
|||
|
|||
#endregion //OverlayBrush
|
|||
|
|||
#region OverlayOpacity
|
|||
|
|||
public static readonly DependencyProperty OverlayOpacityProperty = DependencyProperty.Register("OverlayOpacity", typeof(double), typeof(ChildWindow), new PropertyMetadata(OnOverlayOpacityPropertyChanged)); |
|||
public double OverlayOpacity |
|||
{ |
|||
get { return (double)GetValue(OverlayOpacityProperty); } |
|||
set { SetValue(OverlayOpacityProperty, value); } |
|||
} |
|||
|
|||
private static void OnOverlayOpacityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow cw = (ChildWindow)d; |
|||
|
|||
if (cw.Overlay != null) |
|||
{ |
|||
cw.Overlay.Opacity = (double)e.NewValue; |
|||
} |
|||
} |
|||
|
|||
#endregion //OverlayOpacity
|
|||
|
|||
#region Top
|
|||
|
|||
public static readonly DependencyProperty TopProperty = DependencyProperty.Register("Top", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnTopPropertyChanged))); |
|||
public double Top |
|||
{ |
|||
get { return (double)GetValue(TopProperty); } |
|||
set { SetValue(TopProperty, value); } |
|||
} |
|||
|
|||
private static void OnTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow dialog = (ChildWindow)obj; |
|||
dialog.Top = dialog.GetRestrictedTop(); |
|||
dialog.ProcessMove(0, (double)e.NewValue - (double)e.OldValue); |
|||
} |
|||
|
|||
#endregion //TopProperty
|
|||
|
|||
public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Brush WindowBackground |
|||
{ |
|||
get { return (Brush)GetValue(WindowBackgroundProperty); } |
|||
set { SetValue(WindowBackgroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Brush WindowBorderBrush |
|||
{ |
|||
get { return (Brush)GetValue(WindowBorderBrushProperty); } |
|||
set { SetValue(WindowBorderBrushProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public double WindowOpacity |
|||
{ |
|||
get { return (double)GetValue(WindowOpacityProperty); } |
|||
set { SetValue(WindowOpacityProperty, value); } |
|||
} |
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
void HeaderLeftMouseButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
e.Handled = true; |
|||
Focus(); |
|||
_dragWidget.CaptureMouse(); |
|||
_isMouseCaptured = true; |
|||
_clickPoint = e.GetPosition(null); //save off the mouse position
|
|||
_oldPosition = new Point(Left, Top); //save off our original window position
|
|||
} |
|||
|
|||
private void HeaderMouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
e.Handled = true; |
|||
_dragWidget.ReleaseMouseCapture(); |
|||
_isMouseCaptured = false; |
|||
} |
|||
|
|||
private void HeaderMouseMove(MouseEventArgs e) |
|||
{ |
|||
if (_isMouseCaptured && Visibility == Visibility.Visible) |
|||
{ |
|||
Point currentPosition = e.GetPosition(null); //our current mouse position
|
|||
|
|||
Left = _oldPosition.X + (currentPosition.X - _clickPoint.X); |
|||
Top = _oldPosition.Y + (currentPosition.Y - _clickPoint.Y); |
|||
|
|||
//this helps keep our mouse position in sync with the drag widget position
|
|||
Point dragWidgetPosition = e.GetPosition(_dragWidget); |
|||
if (dragWidgetPosition.X < 0 || dragWidgetPosition.X > _dragWidget.ActualWidth || dragWidgetPosition.Y < 0 || dragWidgetPosition.Y > _dragWidget.ActualHeight) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_oldPosition = new Point(Left, Top); |
|||
_clickPoint = e.GetPosition(Window.GetWindow(this)); //store the point where we are relative to the window
|
|||
} |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
|
|||
#region Methods
|
|||
|
|||
#region Private
|
|||
|
|||
private double GetRestrictedLeft() |
|||
{ |
|||
if (_parent != null) |
|||
{ |
|||
if (Left < 0) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
if (Left + WindowRoot.ActualWidth > _parent.ActualWidth) |
|||
{ |
|||
return _parent.ActualWidth - WindowRoot.ActualWidth; |
|||
} |
|||
} |
|||
|
|||
return Left; |
|||
} |
|||
|
|||
private double GetRestrictedTop() |
|||
{ |
|||
if (_parent != null) |
|||
{ |
|||
if (Top < 0) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
if (Top + WindowRoot.ActualHeight > _parent.ActualHeight) |
|||
{ |
|||
return _parent.ActualHeight - WindowRoot.ActualHeight; |
|||
} |
|||
} |
|||
|
|||
return Top; |
|||
} |
|||
|
|||
private void SetStartupPosition() |
|||
{ |
|||
CenterChildWindow(); |
|||
} |
|||
|
|||
private void CenterChildWindow() |
|||
{ |
|||
_moveTransform.X = _moveTransform.Y = 0; |
|||
|
|||
if (_parent != null) |
|||
{ |
|||
Left = (_parent.ActualWidth - WindowRoot.ActualWidth) / 2.0; |
|||
Top = (_parent.ActualHeight - WindowRoot.ActualHeight) / 2.0; |
|||
} |
|||
} |
|||
|
|||
#endregion //Private
|
|||
|
|||
#region Protected
|
|||
|
|||
protected void ProcessMove(double x, double y) |
|||
{ |
|||
_moveTransform.X += x; |
|||
_moveTransform.Y += y; |
|||
} |
|||
|
|||
#endregion //Protected
|
|||
|
|||
#region Public
|
|||
|
|||
public void Show() |
|||
{ |
|||
Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
|
|||
|
|||
public void Close() |
|||
{ |
|||
Visibility = System.Windows.Visibility.Hidden; |
|||
} |
|||
|
|||
#endregion //Public
|
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,223 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- ChildWindow --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<SolidColorBrush x:Key="ChildWindowMainBrushColor" Color="#FF3C688D"/> |
|||
<LinearGradientBrush x:Key="BorderBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#7FFFFFFF" Offset="0.05"/> |
|||
<GradientStop Color="#B2FFFFFF" Offset="0.07"/> |
|||
<GradientStop Color="#00FFFFFF" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowDarkBrush" 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> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowBackgroundBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFffffff"/> |
|||
<GradientStop Offset="0.479" Color="#FFf4f5f6"/> |
|||
<GradientStop Offset="1" Color="#FFd0d6db"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowButtonHoverBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFb5bdc8"/> |
|||
<GradientStop Offset="0.370" Color="#FF8399a9"/> |
|||
<GradientStop Offset="0.370" Color="#FF718597"/> |
|||
<GradientStop Offset="0.906" Color="#FFb9c1ca"/> |
|||
<GradientStop Offset="1" Color="#FFb9c1ca"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowButtonPressedBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FF6b7c8d"/> |
|||
<GradientStop Offset="0.370" Color="#FF4d606f"/> |
|||
<GradientStop Offset="0.370" Color="#FF465460"/> |
|||
<GradientStop Offset="0.906" Color="#FF262d33"/> |
|||
<GradientStop Offset="1" Color="#FF262d33"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<Style x:Key="ChildWindowCloseButtonStyle" TargetType="Button"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="3"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ChildWindowButtonHoverBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Pressed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ChildWindowButtonPressedBrush}"></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 Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity"> |
|||
<SplineDoubleKeyFrame KeyTime="0" Value="1"/> |
|||
</DoubleAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Unfocused"/> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<Border x:Name="Background" CornerRadius="0,0,2,0" Background="{StaticResource ChildWindowDarkBrush}"> |
|||
<Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/> |
|||
</Border> |
|||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
|||
<Path x:Name="path" |
|||
Height="6" |
|||
Width="7" |
|||
Stretch="Fill" |
|||
Opacity="1" |
|||
Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z" |
|||
Fill="White" Margin="0,0,0,1" Visibility="Collapsed" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style TargetType="{x:Type local:ChildWindow}"> |
|||
<Setter Property="Background" Value="#FFFFFFFF"/> |
|||
<Setter Property="BorderBrush" Value="{StaticResource ChildWindowDarkBrush}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="CaptionForeground" Value="#FF000000" /> |
|||
<Setter Property="CloseButtonStyle" Value="{StaticResource ChildWindowCloseButtonStyle}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
<Setter Property="IsEnabled" Value="true" /> |
|||
<Setter Property="OverlayBrush" Value="#7F000000" /> |
|||
<Setter Property="OverlayOpacity" Value="1" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Top" /> |
|||
<Setter Property="WindowBorderBrush" Value="{StaticResource ChildWindowDarkBrush}" /> |
|||
<Setter Property="WindowBackground" Value="{StaticResource ChildWindowBackgroundBrush}" /> |
|||
<Setter Property="WindowOpacity" Value="1.0" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:ChildWindow}"> |
|||
<Grid x:Name="Root"> |
|||
<Grid x:Name="PART_Overlay" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0" RenderTransformOrigin="0.5,0.5" Background="{TemplateBinding OverlayBrush}" Opacity="{TemplateBinding OverlayOpacity}"/> |
|||
<Grid x:Name="PART_WindowRoot" HorizontalAlignment="Left" VerticalAlignment="Top"> |
|||
<Grid.RenderTransform> |
|||
<TransformGroup> |
|||
<ScaleTransform /> |
|||
<SkewTransform /> |
|||
<RotateTransform /> |
|||
<TranslateTransform /> |
|||
</TransformGroup> |
|||
</Grid.RenderTransform> |
|||
|
|||
<!-- Borders --> |
|||
<Grid x:Name="WindowGrid"> |
|||
<Border BorderBrush="{TemplateBinding WindowBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5,5,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Grid Margin="0" Background="{x:Null}"> |
|||
<Border x:Name="WindowBorder" Margin="1,1,1,1" Background="{TemplateBinding WindowBackground}" CornerRadius="4,4,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Border BorderBrush="White" BorderThickness="1" CornerRadius="4,4,0,0" Margin="1" Opacity="0.7"/> |
|||
</Grid> |
|||
</Grid> |
|||
|
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto" MinHeight="26"/> |
|||
<RowDefinition /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<!-- Content Border --> |
|||
<Grid Margin="6,0,6,6" x:Name="ContentGrid" Grid.Row="1"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
<Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1"/> |
|||
<Border Margin="1" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0.1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"> |
|||
|
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition /> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Cursor="{TemplateBinding Cursor}"/> |
|||
|
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
</Grid> |
|||
|
|||
<!-- Header --> |
|||
<Border x:Name="PART_DragWidget" Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0"> |
|||
<Grid> |
|||
<Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center"> |
|||
<!-- Caption --> |
|||
<ContentControl x:Name="Caption" Margin="5,0,0,0" IsTabStop="False" HorizontalAlignment="Stretch" |
|||
Content="{TemplateBinding Caption}" |
|||
Foreground="{TemplateBinding CaptionForeground}"/> |
|||
|
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
|
|||
<!-- Buttons --> |
|||
<Border BorderBrush="#A5FFFFFF" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3" VerticalAlignment="Top" Margin="0,1,7,0" HorizontalAlignment="Right"> |
|||
<Button x:Name="PART_CloseButton" Style="{TemplateBinding CloseButtonStyle}" Visibility="{TemplateBinding CloseButtonVisibility}" Height="17" Width="43" IsTabStop="False"> |
|||
<Path Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Width="12" Fill="#E4FFFFFF" Stretch="Fill" Stroke="#FF535666" |
|||
Data="M0.5,0.5 L4.5178828,0.5 L6.0620003,3.125 L7.4936447,0.5 L11.5,0.5 L11.5,1.5476431 L8.7425003,6.1201854 L11.5,10.359666 L11.5,11.5 L7.4941902,11.5 L6.0620003,8.8740005 L4.5172949,11.5 L0.5,11.5 L0.5,10.43379 L3.3059995,6.1201582 L0.5,1.4676378 L0.5,0.5 z"/> |
|||
</Button> |
|||
</Border> |
|||
</Grid> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
Loading…
Reference in new issue