teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

再回答

2017/02/24 07:12

投稿

sugar_yas
sugar_yas

スコア135

answer CHANGED
@@ -1,2 +1,115 @@
1
1
  以下のサイトが参考になるかもしれません。
2
- [システムメニューを操作するビヘイビア](http://blog.xin9le.net/entry/2013/11/06/021557)
2
+ [システムメニューを操作するビヘイビア](http://blog.xin9le.net/entry/2013/11/06/021557)
3
+
4
+ ---
5
+
6
+ 2017/2/24 追記
7
+ ---
8
+ タイトルバーを編集でぐぐって、以下のサイトを見つけました。
9
+ [WPF で Zune のようなウィンドウを作る](http://grabacr.net/archives/480)
10
+ タイトルバーを削除し、メイン領域の上段をタイトルバーに見立てるように、
11
+ 自前で作成するようです。
12
+
13
+ ```MainWindow.xaml
14
+ <Window x:Class="WpfApplication3.MainWindow"
15
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
16
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
17
+ Title="MainWindow" Height="350" Width="525" SnapsToDevicePixels="True"
18
+ Background="Black">
19
+ <WindowChrome.WindowChrome>
20
+ <!-- WindowChrome CaptionHeightの高さ分がタイトルバーの高さとして扱う -->
21
+ <WindowChrome CaptionHeight="{x:Static SystemParameters.CaptionHeight}"
22
+ ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
23
+ </WindowChrome.WindowChrome>
24
+
25
+ <Window.Resources>
26
+ <Style x:Key="CaptionButtonStyleKey" TargetType="{x:Type Button}">
27
+ <Setter Property="OverridesDefaultStyle" Value="True" />
28
+ <Setter Property="Foreground" Value="White" />
29
+ <Setter Property="FontFamily" Value="Marlett"/>
30
+ <Setter Property="IsTabStop" Value="False"/>
31
+ <Setter Property="HorizontalContentAlignment" Value="Center" />
32
+ <Setter Property="VerticalContentAlignment" Value="Center" />
33
+ <Setter Property="Margin" Value="2" />
34
+ <Setter Property="Padding" Value="1" />
35
+ <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
36
+ <Setter Property="Template">
37
+ <Setter.Value>
38
+ <ControlTemplate TargetType="{x:Type Button}">
39
+ <Border x:Name="border" Background="Transparent" SnapsToDevicePixels="True">
40
+ <Border.Effect>
41
+ <DropShadowEffect Opacity="0"/>
42
+ </Border.Effect>
43
+ <VisualStateManager.VisualStateGroups>
44
+ <VisualStateGroup x:Name="CommonStates">
45
+ <VisualState x:Name="Normal">
46
+ <Storyboard>
47
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
48
+ <EasingDoubleKeyFrame KeyTime="0" Value="0.6"/>
49
+ </DoubleAnimationUsingKeyFrames>
50
+ </Storyboard>
51
+ </VisualState>
52
+ <VisualState x:Name="MouseOver">
53
+ <Storyboard>
54
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
55
+ <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
56
+ </DoubleAnimationUsingKeyFrames>
57
+ </Storyboard>
58
+ </VisualState>
59
+ <VisualState x:Name="Pressed">
60
+ <Storyboard>
61
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
62
+ <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
63
+ </DoubleAnimationUsingKeyFrames>
64
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="border">
65
+ <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
66
+ </DoubleAnimationUsingKeyFrames>
67
+ <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="border">
68
+ <EasingColorKeyFrame KeyTime="0" Value="White"/>
69
+ </ColorAnimationUsingKeyFrames>
70
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="border">
71
+ <EasingDoubleKeyFrame KeyTime="0" Value="0.6"/>
72
+ </DoubleAnimationUsingKeyFrames>
73
+ </Storyboard>
74
+ </VisualState>
75
+ <VisualState x:Name="Disabled"/>
76
+ </VisualStateGroup>
77
+ </VisualStateManager.VisualStateGroups>
78
+ <ContentPresenter x:Name="contentPresenter" Focusable="False" Margin="{TemplateBinding Padding}"
79
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
80
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
81
+ </Border>
82
+ </ControlTemplate>
83
+ </Setter.Value>
84
+ </Setter>
85
+ <Setter Property="FocusVisualStyle" Value="{x:Null}" />
86
+ </Style>
87
+ </Window.Resources>
88
+
89
+ <Border BorderBrush="Gray"
90
+ BorderThickness="1">
91
+ <Grid>
92
+ <!-- イメージとタイトルの追加 -->
93
+ <StackPanel Orientation="Horizontal" Margin="5"
94
+ HorizontalAlignment="Left"
95
+ VerticalAlignment="Top">
96
+ <Image Source="./Folder.ico" Width="20" Height="20" />
97
+ <TextBlock Text="タイトル" Foreground="White" />
98
+ </StackPanel>
99
+
100
+ <!-- ×ボタンの削除と、各ボタンのクリックイベントを実装 -->
101
+ <StackPanel Orientation="Horizontal" Margin="5"
102
+ HorizontalAlignment="Right"
103
+ VerticalAlignment="Top">
104
+ <Button Name="MinButton" Content="0" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
105
+ <Button Name="MaxButton" Content="1" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
106
+ <Button Name="OriginalSizeButton" Content="2" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
107
+ </StackPanel>
108
+ </Grid>
109
+ </Border>
110
+ </Window>
111
+
112
+
113
+ ```
114
+ 実行例
115
+ ![実行例](618c2120c0c83a1fed0add25b804e732.png)

1

URL 修正

2017/02/24 07:12

投稿

sugar_yas
sugar_yas

スコア135

answer CHANGED
@@ -1,2 +1,2 @@
1
1
  以下のサイトが参考になるかもしれません。
2
- [システムメニューを操作するビヘイビア](http://blog.xin9le.net/entry/2013/11/06/021557http://)
2
+ [システムメニューを操作するビヘイビア](http://blog.xin9le.net/entry/2013/11/06/021557)