回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
参考コードがある場合は出典を質問に**明示**してください。
|
2
|
-
[WPF で DropDown メニューボタン - アカベコマイリ](https://akabeko.me/blog/2009/10/wpf-dropdown-menu-button/)
|
3
|
-
|
4
|
-
中に入っているのがボタンなのは、意図してやっているということでいいんでしょうか?(すごい違和感があるのですが)
|
5
|
-
|
6
|
-
ボタンでいいならこんな感じでしょうか。
|
7
|
-
|
8
|
-
```
|
9
|
-
<Window
|
10
|
-
x:Class="Questions359466.MainWindow"
|
11
|
-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
12
|
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
13
|
-
xmlns:l="clr-namespace:Questions359466"
|
14
|
-
Width="400"
|
15
|
-
Height="200">
|
16
|
-
<StackPanel
|
17
|
-
HorizontalAlignment="Center"
|
18
|
-
VerticalAlignment="Center"
|
19
|
-
Orientation="Horizontal">
|
20
|
-
|
21
|
-
<l:DropDownMenuButton MinWidth="120" Content="normal">
|
22
|
-
<l:DropDownMenuButton.DropDownContextMenu>
|
23
|
-
<ContextMenu>
|
24
|
-
<Button Content="AAAA" />
|
25
|
-
<Button Content="BBBB" />
|
26
|
-
</ContextMenu>
|
27
|
-
</l:DropDownMenuButton.DropDownContextMenu>
|
28
|
-
</l:DropDownMenuButton>
|
29
|
-
|
30
|
-
<l:DropDownMenuButton MinWidth="120" Content="no highlight">
|
31
|
-
<l:DropDownMenuButton.DropDownContextMenu>
|
32
|
-
<ContextMenu>
|
33
|
-
<ContextMenu.Resources>
|
34
|
-
<Style TargetType="{x:Type MenuItem}">
|
35
|
-
<Setter Property="Template">
|
36
|
-
<Setter.Value>
|
37
|
-
<ControlTemplate TargetType="{x:Type MenuItem}">
|
38
|
-
<ContentPresenter ContentSource="Header" />
|
39
|
-
</ControlTemplate>
|
40
|
-
</Setter.Value>
|
41
|
-
</Setter>
|
42
|
-
</Style>
|
43
|
-
</ContextMenu.Resources>
|
44
|
-
<Button Content="AAAA" />
|
45
|
-
<Button Content="BBBB" />
|
46
|
-
</ContextMenu>
|
47
|
-
</l:DropDownMenuButton.DropDownContextMenu>
|
48
|
-
</l:DropDownMenuButton>
|
49
|
-
</StackPanel>
|
50
|
-
</Window>
|
1
|
+
参考コードがある場合は出典を質問に**明示**してください。
|
2
|
+
[WPF で DropDown メニューボタン - アカベコマイリ](https://akabeko.me/blog/2009/10/wpf-dropdown-menu-button/)
|
3
|
+
|
4
|
+
中に入っているのがボタンなのは、意図してやっているということでいいんでしょうか?(すごい違和感があるのですが)
|
5
|
+
|
6
|
+
ボタンでいいならこんな感じでしょうか。
|
7
|
+
|
8
|
+
```xml
|
9
|
+
<Window
|
10
|
+
x:Class="Questions359466.MainWindow"
|
11
|
+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
12
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
13
|
+
xmlns:l="clr-namespace:Questions359466"
|
14
|
+
Width="400"
|
15
|
+
Height="200">
|
16
|
+
<StackPanel
|
17
|
+
HorizontalAlignment="Center"
|
18
|
+
VerticalAlignment="Center"
|
19
|
+
Orientation="Horizontal">
|
20
|
+
|
21
|
+
<l:DropDownMenuButton MinWidth="120" Content="normal">
|
22
|
+
<l:DropDownMenuButton.DropDownContextMenu>
|
23
|
+
<ContextMenu>
|
24
|
+
<Button Content="AAAA" />
|
25
|
+
<Button Content="BBBB" />
|
26
|
+
</ContextMenu>
|
27
|
+
</l:DropDownMenuButton.DropDownContextMenu>
|
28
|
+
</l:DropDownMenuButton>
|
29
|
+
|
30
|
+
<l:DropDownMenuButton MinWidth="120" Content="no highlight">
|
31
|
+
<l:DropDownMenuButton.DropDownContextMenu>
|
32
|
+
<ContextMenu>
|
33
|
+
<ContextMenu.Resources>
|
34
|
+
<Style TargetType="{x:Type MenuItem}">
|
35
|
+
<Setter Property="Template">
|
36
|
+
<Setter.Value>
|
37
|
+
<ControlTemplate TargetType="{x:Type MenuItem}">
|
38
|
+
<ContentPresenter ContentSource="Header" />
|
39
|
+
</ControlTemplate>
|
40
|
+
</Setter.Value>
|
41
|
+
</Setter>
|
42
|
+
</Style>
|
43
|
+
</ContextMenu.Resources>
|
44
|
+
<Button Content="AAAA" />
|
45
|
+
<Button Content="BBBB" />
|
46
|
+
</ContextMenu>
|
47
|
+
</l:DropDownMenuButton.DropDownContextMenu>
|
48
|
+
</l:DropDownMenuButton>
|
49
|
+
</StackPanel>
|
50
|
+
</Window>
|
51
51
|
```
|