回答編集履歴

2

再回答

2017/02/24 07:12

投稿

sugar_yas
sugar_yas

スコア135

test CHANGED
@@ -1,3 +1,229 @@
1
1
  以下のサイトが参考になるかもしれません。
2
2
 
3
3
  [システムメニューを操作するビヘイビア](http://blog.xin9le.net/entry/2013/11/06/021557)
4
+
5
+
6
+
7
+ ---
8
+
9
+
10
+
11
+ 2017/2/24 追記
12
+
13
+ ---
14
+
15
+ タイトルバーを編集でぐぐって、以下のサイトを見つけました。
16
+
17
+ [WPF で Zune のようなウィンドウを作る](http://grabacr.net/archives/480)
18
+
19
+ タイトルバーを削除し、メイン領域の上段をタイトルバーに見立てるように、
20
+
21
+ 自前で作成するようです。
22
+
23
+
24
+
25
+ ```MainWindow.xaml
26
+
27
+ <Window x:Class="WpfApplication3.MainWindow"
28
+
29
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
30
+
31
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
32
+
33
+ Title="MainWindow" Height="350" Width="525" SnapsToDevicePixels="True"
34
+
35
+ Background="Black">
36
+
37
+ <WindowChrome.WindowChrome>
38
+
39
+ <!-- WindowChrome CaptionHeightの高さ分がタイトルバーの高さとして扱う -->
40
+
41
+ <WindowChrome CaptionHeight="{x:Static SystemParameters.CaptionHeight}"
42
+
43
+ ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
44
+
45
+ </WindowChrome.WindowChrome>
46
+
47
+
48
+
49
+ <Window.Resources>
50
+
51
+ <Style x:Key="CaptionButtonStyleKey" TargetType="{x:Type Button}">
52
+
53
+ <Setter Property="OverridesDefaultStyle" Value="True" />
54
+
55
+ <Setter Property="Foreground" Value="White" />
56
+
57
+ <Setter Property="FontFamily" Value="Marlett"/>
58
+
59
+ <Setter Property="IsTabStop" Value="False"/>
60
+
61
+ <Setter Property="HorizontalContentAlignment" Value="Center" />
62
+
63
+ <Setter Property="VerticalContentAlignment" Value="Center" />
64
+
65
+ <Setter Property="Margin" Value="2" />
66
+
67
+ <Setter Property="Padding" Value="1" />
68
+
69
+ <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
70
+
71
+ <Setter Property="Template">
72
+
73
+ <Setter.Value>
74
+
75
+ <ControlTemplate TargetType="{x:Type Button}">
76
+
77
+ <Border x:Name="border" Background="Transparent" SnapsToDevicePixels="True">
78
+
79
+ <Border.Effect>
80
+
81
+ <DropShadowEffect Opacity="0"/>
82
+
83
+ </Border.Effect>
84
+
85
+ <VisualStateManager.VisualStateGroups>
86
+
87
+ <VisualStateGroup x:Name="CommonStates">
88
+
89
+ <VisualState x:Name="Normal">
90
+
91
+ <Storyboard>
92
+
93
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
94
+
95
+ <EasingDoubleKeyFrame KeyTime="0" Value="0.6"/>
96
+
97
+ </DoubleAnimationUsingKeyFrames>
98
+
99
+ </Storyboard>
100
+
101
+ </VisualState>
102
+
103
+ <VisualState x:Name="MouseOver">
104
+
105
+ <Storyboard>
106
+
107
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
108
+
109
+ <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
110
+
111
+ </DoubleAnimationUsingKeyFrames>
112
+
113
+ </Storyboard>
114
+
115
+ </VisualState>
116
+
117
+ <VisualState x:Name="Pressed">
118
+
119
+ <Storyboard>
120
+
121
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
122
+
123
+ <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
124
+
125
+ </DoubleAnimationUsingKeyFrames>
126
+
127
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="border">
128
+
129
+ <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
130
+
131
+ </DoubleAnimationUsingKeyFrames>
132
+
133
+ <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="border">
134
+
135
+ <EasingColorKeyFrame KeyTime="0" Value="White"/>
136
+
137
+ </ColorAnimationUsingKeyFrames>
138
+
139
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="border">
140
+
141
+ <EasingDoubleKeyFrame KeyTime="0" Value="0.6"/>
142
+
143
+ </DoubleAnimationUsingKeyFrames>
144
+
145
+ </Storyboard>
146
+
147
+ </VisualState>
148
+
149
+ <VisualState x:Name="Disabled"/>
150
+
151
+ </VisualStateGroup>
152
+
153
+ </VisualStateManager.VisualStateGroups>
154
+
155
+ <ContentPresenter x:Name="contentPresenter" Focusable="False" Margin="{TemplateBinding Padding}"
156
+
157
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
158
+
159
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
160
+
161
+ </Border>
162
+
163
+ </ControlTemplate>
164
+
165
+ </Setter.Value>
166
+
167
+ </Setter>
168
+
169
+ <Setter Property="FocusVisualStyle" Value="{x:Null}" />
170
+
171
+ </Style>
172
+
173
+ </Window.Resources>
174
+
175
+
176
+
177
+ <Border BorderBrush="Gray"
178
+
179
+ BorderThickness="1">
180
+
181
+ <Grid>
182
+
183
+ <!-- イメージとタイトルの追加 -->
184
+
185
+ <StackPanel Orientation="Horizontal" Margin="5"
186
+
187
+ HorizontalAlignment="Left"
188
+
189
+ VerticalAlignment="Top">
190
+
191
+ <Image Source="./Folder.ico" Width="20" Height="20" />
192
+
193
+ <TextBlock Text="タイトル" Foreground="White" />
194
+
195
+ </StackPanel>
196
+
197
+
198
+
199
+ <!-- ×ボタンの削除と、各ボタンのクリックイベントを実装 -->
200
+
201
+ <StackPanel Orientation="Horizontal" Margin="5"
202
+
203
+ HorizontalAlignment="Right"
204
+
205
+ VerticalAlignment="Top">
206
+
207
+ <Button Name="MinButton" Content="0" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
208
+
209
+ <Button Name="MaxButton" Content="1" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
210
+
211
+ <Button Name="OriginalSizeButton" Content="2" Style="{DynamicResource CaptionButtonStyleKey}" Click="Button_Click" />
212
+
213
+ </StackPanel>
214
+
215
+ </Grid>
216
+
217
+ </Border>
218
+
219
+ </Window>
220
+
221
+
222
+
223
+
224
+
225
+ ```
226
+
227
+ 実行例
228
+
229
+ ![実行例](618c2120c0c83a1fed0add25b804e732.png)

1

URL 修正

2017/02/24 07:12

投稿

sugar_yas
sugar_yas

スコア135

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