Skip to content

Commit b65b8d2

Browse files
Merge pull request #55 from WPFDevelopersOrg/dev
dev pull requese master
2 parents e44312b + a6fdb62 commit b65b8d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1416
-342
lines changed

src/WPFDevelopers.Net40/Themes/Generic.xaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
55
xmlns:shell="clr-namespace:Microsoft.Windows.Shell"
6-
xmlns:wpfdev="clr-namespace:WPFDevelopers.Net40">
6+
xmlns:wd="clr-namespace:WPFDevelopers.Net40">
77
<converts:ObjectNullToVisibilityConverter x:Key="ObjectNullToVisibilityConverter" />
8-
<Style BasedOn="{x:Null}" TargetType="{x:Type wpfdev:Window}">
8+
<Style BasedOn="{x:Null}" TargetType="{x:Type wd:Window}">
99
<Setter Property="Foreground" Value="{DynamicResource WD.WindowForegroundColorBrush}" />
1010
<Setter Property="Background" Value="{DynamicResource WD.BackgroundSolidColorBrush}" />
1111
<Setter Property="BorderBrush" Value="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" />
@@ -19,12 +19,12 @@
1919
<Setter Property="FontFamily" Value="{DynamicResource WD.NormalFontFamily}" />
2020
<Setter Property="shell:WindowChrome.WindowChrome">
2121
<Setter.Value>
22-
<shell:WindowChrome CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wpfdev:Window}}" GlassFrameThickness="0,0,0,.1" />
22+
<shell:WindowChrome CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wd:Window}}" GlassFrameThickness="0,0,0,.1" />
2323
</Setter.Value>
2424
</Setter>
2525
<Setter Property="Template">
2626
<Setter.Value>
27-
<ControlTemplate TargetType="{x:Type wpfdev:Window}">
27+
<ControlTemplate TargetType="{x:Type wd:Window}">
2828
<Border
2929
BorderBrush="{TemplateBinding BorderBrush}"
3030
BorderThickness="{TemplateBinding BorderThickness}"
@@ -35,6 +35,7 @@
3535
<RowDefinition Height="*" />
3636
</Grid.RowDefinitions>
3737
<Grid
38+
x:Name="PART_GridChrome"
3839
Grid.Row="0"
3940
Height="{TemplateBinding TitleHeight}"
4041
Background="{TemplateBinding BorderBrush}">
@@ -138,6 +139,13 @@
138139
</Button>
139140
</WrapPanel>
140141
</Grid>
142+
<ContentPresenter
143+
x:Name="PART_TitleToolBar"
144+
Grid.Row="0"
145+
shell:WindowChrome.IsHitTestVisibleInChrome="True"
146+
Content="{Binding TitleBar, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
147+
Focusable="False"
148+
Visibility="Collapsed" />
141149
<AdornerDecorator Grid.Row="1" KeyboardNavigation.IsTabStop="False">
142150
<ContentPresenter x:Name="MainContentPresenter" ClipToBounds="True" />
143151
</AdornerDecorator>
@@ -159,6 +167,10 @@
159167
<Trigger Property="WindowStyle" Value="ToolWindow">
160168
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
161169
</Trigger>
170+
<Trigger Property="NoChrome" Value="True">
171+
<Setter TargetName="PART_GridChrome" Property="Visibility" Value="Collapsed" />
172+
<Setter TargetName="PART_TitleToolBar" Property="Visibility" Value="Visible" />
173+
</Trigger>
162174
<MultiTrigger>
163175
<MultiTrigger.Conditions>
164176
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />

src/WPFDevelopers.Net40/Themes/Theme.xaml

Lines changed: 137 additions & 29 deletions
Large diffs are not rendered by default.

src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<IncludeSymbols>true</IncludeSymbols>
99
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1010
<Copyright>Copyright © WPFDevelopersOrg 2022</Copyright>
11-
<AssemblyVersion>1.1.0.1</AssemblyVersion>
12-
<FileVersion>1.1.0.1</FileVersion>
13-
<Version>1.1.0.1</Version>
11+
<AssemblyVersion>1.1.0.2</AssemblyVersion>
12+
<FileVersion>1.1.0.2</FileVersion>
13+
<Version>1.1.0.2</Version>
1414
<RepositoryUrl>https://github.com/WPFDevelopersOrg/WPFDevelopers</RepositoryUrl>
1515
<Configurations>Debug;Release;Debug-.NET40;Release-.NET40</Configurations>
1616
</PropertyGroup>

src/WPFDevelopers.Net40/Window.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows.Controls;
55
using System.Windows.Input;
66
using System.Windows.Interop;
7+
using System.Windows.Media;
78
using Microsoft.Windows.Shell;
89
using WPFDevelopers.Helpers;
910

@@ -12,9 +13,16 @@ namespace WPFDevelopers.Net40
1213
public class Window : System.Windows.Window
1314
{
1415
private WindowStyle _windowStyle;
16+
1517
public static readonly DependencyProperty TitleHeightProperty =
1618
DependencyProperty.Register("TitleHeight", typeof(double), typeof(Window), new PropertyMetadata(50d));
1719

20+
public static readonly DependencyProperty NoChromeProperty =
21+
DependencyProperty.Register("NoChrome", typeof(bool), typeof(Window), new PropertyMetadata(false));
22+
23+
public static readonly DependencyProperty TitleBarProperty =
24+
DependencyProperty.Register("TitleBar", typeof(object), typeof(Window), new PropertyMetadata(null));
25+
1826
static Window()
1927
{
2028
DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(typeof(Window)));
@@ -43,6 +51,18 @@ public double TitleHeight
4351
set => SetValue(TitleHeightProperty, value);
4452
}
4553

54+
public bool NoChrome
55+
{
56+
get => (bool)GetValue(NoChromeProperty);
57+
set => SetValue(NoChromeProperty, value);
58+
}
59+
60+
public object TitleBar
61+
{
62+
get => (object)GetValue(TitleBarProperty);
63+
set => SetValue(TitleBarProperty, value);
64+
}
65+
4666
private void Window_Loaded(object sender, RoutedEventArgs e)
4767
{
4868
hWnd = new WindowInteropHelper(this).Handle;
@@ -70,23 +90,16 @@ private void CanMinimizeWindow(object sender, CanExecuteRoutedEventArgs e)
7090

7191
private void CloseWindow(object sender, ExecutedRoutedEventArgs e)
7292
{
73-
//Close();
7493
SystemCommands.CloseWindow(this);
7594
}
7695

7796
private void MaximizeWindow(object sender, ExecutedRoutedEventArgs e)
7897
{
7998
SystemCommands.MaximizeWindow(this);
80-
//var window = sender as Window;
81-
//window.WindowState = WindowState.Maximized;
82-
//WindowState = WindowState.Maximized;
8399
}
84100

85101
private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e)
86102
{
87-
//SystemCommands.MinimizeWindow(this);
88-
//WindowStyle = WindowStyle.SingleBorderWindow;
89-
//WindowState = WindowState.Minimized;
90103
SendMessage(hWnd, ApiCodes.WM_SYSCOMMAND, new IntPtr(ApiCodes.SC_MINIMIZE), IntPtr.Zero);
91104
}
92105

src/WPFDevelopers.Net45x/Themes/Generic.xaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
5-
xmlns:wpfdev="clr-namespace:WPFDevelopers.Net45x">
5+
xmlns:wd="clr-namespace:WPFDevelopers.Net45x">
66
<converts:ObjectNullToVisibilityConverter x:Key="ObjectNullToVisibilityConverter" />
77
<Style
88
x:Key="WPFDevelopersWindow"
99
BasedOn="{x:Null}"
10-
TargetType="{x:Type wpfdev:Window}">
10+
TargetType="{x:Type wd:Window}">
1111
<Setter Property="Foreground" Value="{DynamicResource WD.WindowForegroundColorBrush}" />
1212
<Setter Property="Background" Value="{DynamicResource WD.BackgroundSolidColorBrush}" />
1313
<Setter Property="BorderBrush" Value="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" />
@@ -23,14 +23,14 @@
2323
<Setter Property="WindowChrome.WindowChrome">
2424
<Setter.Value>
2525
<WindowChrome
26-
CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wpfdev:Window}}"
26+
CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wd:Window}}"
2727
GlassFrameThickness="0,0,0,.1"
2828
UseAeroCaptionButtons="False" />
2929
</Setter.Value>
3030
</Setter>
3131
<Setter Property="Template">
3232
<Setter.Value>
33-
<ControlTemplate TargetType="{x:Type wpfdev:Window}">
33+
<ControlTemplate TargetType="{x:Type wd:Window}">
3434
<Border
3535
BorderBrush="{TemplateBinding BorderBrush}"
3636
BorderThickness="{TemplateBinding BorderThickness}"
@@ -41,6 +41,7 @@
4141
<RowDefinition Height="*" />
4242
</Grid.RowDefinitions>
4343
<Grid
44+
x:Name="PART_GridChrome"
4445
Grid.Row="0"
4546
Height="{TemplateBinding TitleHeight}"
4647
Background="{TemplateBinding BorderBrush}">
@@ -144,6 +145,13 @@
144145
</Button>
145146
</WrapPanel>
146147
</Grid>
148+
<ContentPresenter
149+
x:Name="PART_TitleToolBar"
150+
Grid.Row="0"
151+
Content="{Binding TitleBar, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
152+
Focusable="False"
153+
Visibility="Collapsed"
154+
WindowChrome.IsHitTestVisibleInChrome="True" />
147155
<AdornerDecorator Grid.Row="1" KeyboardNavigation.IsTabStop="False">
148156
<ContentPresenter x:Name="MainContentPresenter" ClipToBounds="True" />
149157
</AdornerDecorator>
@@ -165,6 +173,10 @@
165173
<Trigger Property="WindowStyle" Value="ToolWindow">
166174
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
167175
</Trigger>
176+
<Trigger Property="NoChrome" Value="True">
177+
<Setter TargetName="PART_GridChrome" Property="Visibility" Value="Collapsed" />
178+
<Setter TargetName="PART_TitleToolBar" Property="Visibility" Value="Visible" />
179+
</Trigger>
168180
<MultiTrigger>
169181
<MultiTrigger.Conditions>
170182
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />

0 commit comments

Comments
 (0)